A person "leaves" Thailand when they cross over passport control. They can be physically in Thailand, at the departure terminal for multiple days, but as long as they have that "departure" stamp, they legally left Thailand.
By land: Twice in a calendar year (note: Land borders are closed). By air: "Unlimited", until the passport control officer believes you're abusing the system.
For a tourist visa, a person is allowed to spend 60 days. Tourist visas can only be acquired outside of Thailand. ONE 30 day extension of stay based on tourism can be acquired on this visa, giving a total of 90 days.
A person can get "unlimited" tourist visas from the Thai consulate. The amount that can be granted depends on the consulate being used.