Question: I'd like to stay in the EU for some time, maybe get a residence permit if possible. The question is what are my healthcare options. As far as I know, citizens of EU countries can get public healthcare coverage. Can I get this by paying for it? Are there any alternatives for people with a residence permit yet without citizenship? Obviously, there's an option of travel insurance but I hope that for a longer stay there might be options with better or at least cheaper coverage.

Answer: 
That's not exactly the way it works, health insurance is typically based on residence or (mandatory) contributions. I have varying level of familiarity with the healthcare system in half-a-dozen EU countries and I do not know a single one that would offer free coverage to citizens *qua* citizens.

In some cases, living and working in a country would in fact provide you with (statutory) health insurance coverage. In others, having independent health insurance coverage is a requirement to get a residence permit in the first place. Citizenship, however seldom makes a huge difference (save for the fact you can always come back even in situation where you wouldn't qualify for a residence permit).
Yes - you can get on local health insurance in some countries in the EU. It is managed on a country-by-country basis. I know Switzerland, for one, would require foreign nationals who get residency to purchase a local health insurance plan (<https://www.bag.admin.ch/bag/en/home/versicherungen/krankenversicherung.html>). I believe Portugal and Spain are the same. So it might be worth picking a few countries and researching if they allow foreign nationals residing in those countries to move onto their local national plans.