Foreign students normally enter via a non-immigrant visa (F1), or rather they are eligible to apply for that visa at an embassy, if a registered sponsor supports it. The visa permits a request for entry into the country for the purpose of study (at a port of entry). The most important document that you need day to day is a DS-2019 and you must remain "in F1 status" in the SEVIS system for the duration of your program. If you don't leave the US, you don't need another visa even if your original one expires, the university can issue you a new DS-2019 annually until your end-of-program date. That's up to 5 years dependent on the category. If you leave after your visa expires you have to renew it out of the country, which is normally straightforward (using the dropbox system).
The government has not prevented foreign people from studying or working at Harvard, they have withdrawn their ability to maintain status while at Harvard. Hence why they can transfer to another institution.
You can view the DS-2019 as more like a work permit. The visa lets you leave and re-enter the country.
Some European countries work in a comparable way where you don't need a visa at all (depending where you're from), but you can't stay unless you have a valid work permit.
Foreign students normally enter via a non-immigrant visa (F1), or rather they are eligible to apply for that visa at an embassy, if a registered sponsor supports it. The visa permits a request for entry into the country for the purpose of study (at a port of entry). The most important document that you need day to day is a DS-2019 and you must remain "in F1 status" in the SEVIS system for the duration of your program. If you don't leave the US, you don't need another visa even if your original one expires, the university can issue you a new DS-2019 annually until your end-of-program date. That's up to 5 years dependent on the category. If you leave after your visa expires you have to renew it out of the country, which is normally straightforward (using the dropbox system).
The government has not prevented foreign people from studying or working at Harvard, they have withdrawn their ability to maintain status while at Harvard. Hence why they can transfer to another institution.