Depending on which EU country it is though. It is bit of a minefield just getting the right information, but some will allow you to apply for a residence permit if you are quick, or if you had one pre-brexit to have this switched to the a new post brexit "third country" status. Just because you have residency in another country, doesn't automatically mean you have to port across your access to the UK health system, or state pension too, that's a separate process. I applied for and had residency granted in an Eu country in May 2019 which was valid originally for 5 years as I saw this coming.
I went back last month for the first time in 15 months because I had until the end of June to apply for the new post brexit version as my existing permit expiry had been brought forward to December 31st 2021. Made the application and provided the docs, had the interview, but needed to wait 30 days this time for a decision. Apparently this was due to the need for a check to be made with interpol, something that wasn't required when I made the last application due to being a Eu citizen then. Anyhow, 30 days later, and I get the news that my new permit for 5 years is waiting for me to collect. Hardest and certainly the most expensive thing, was getting back into the UK.
Edit. Just seen the other thread and see it's Spain you were hoping for. Too late I think, but things may change in the future.