Yes foreigners can buy real estate in the U.S. However, you will need a large down payment (about 30%) and get a mortgage loan for the balance. You need to Google FIRPTA because you will need to pay taxes when you sell. Finally, buying property does not give you any residency status and if you are not legally in the U.S. you can get deported.
I'm a former realtor and still in contact with lenders so this is the latest from lenders.