Yes a foreigner can own a house, the land would be on a leasehold. Just like buying a house in Mexico, except there it is a 99 year lease, or like in the US when you buy a house on BLM land where you lease the land from the BLM.
In case of a foreigner buying real estate in Thailand, the ownership of a house can be registered and transferred separately from the land where the house is built;
The transfer procedure must be in accordance with the Thailand Civil and Commercial Code;
The transfer must be in writing;
The transfer must be registered with the Land Department's branch or provincial office.
Sale and transfer of ownership of an existing building separate from the land requires the current owner and buyer of the house to strictly conform with the standard procedure at the Land Office.