I'm a UK citizen, resident in Norway, who has visited Poland on business many time.
I stayed a night in the Krakow Neurological Institute somewhere between fifteen and twenty years ago, cost me about 100 USD. The ambulance that took me there was free.
A few minutes later we saw the helicopter lift from the hospital and head straight towards us. Down came the rescue equipment and Dr Bruno, who told us not to worry because "We do this all the time!". 10 minutes later he was ascending with the patient.
I learned two things: Doctors in Switzerland really do do this stuff all the time, and always have hiking accidents near well-equipped medical facilities that aren't trying to totally screw people over.
I'm pretty sure it was the best $2500 that guy ever spent.
Almost all.
Non citizens just pay a fee or are reinbursed later by their insurance or healthcare system. In many cases citizens from country 'A' can use healthcare in 'B' as long as their own citizens will be granted the same treatment in exchange when visiting 'A'. It depends on the treatises signed between the two countries.
Allowing foreigners to use the health care system for free is sometimes allowed (or even encouraged) if that protects the interests of the country.