Why does Switzerland prevent foreign students from studying medicine?
In Switzerland, access to medicine, dentistry and veterinary is limited due to high demand (also for Swiss students). The test for admission is called Numerus clauses and it was introduced because the capacity of the universities are too low and demand too high. Basically they are allowed to test students if demand is more than 20% above capacity. 

Regarding the information about foreign students, this does not seem to be the case. On the University of Zurich website (in German http://www.med.uzh.ch/Medizinstudium/humanmedizinstudium.html ) they state that everybody, Swiss and foreigners, have to take the test but in principle foreign students can study medicine at a Swiss university (at least according to UZH):


  Zum Medizinstudium sind Schweizerinnen und Schweizer sowie Ausländerinnen und Ausländer, die bestimmte Zulassungskriterien erfüllen müssen, zugelassen