Since the end of the transition period on 1/1/21 British citizens no longer enjoy freedom of movement within the Schengen area including Spain. You can spend 90 days in any 180 day period in this area visa free. But if you want to spend more than 90 days at a time in Spain you will need to apply for a long-stay visa.
There are numerous visas that are available. But if you want to stay long-term in Spain and not work i.e. you are retired, then the non-lucrative visa will likely be the most suitable choice.