Who is bidding
The lender almost always bids first, often up to the amount you owe. This is called a credit bid because the lender does not pay cash. Investors bid with cash or certified funds. If nobody bids more than the lender, the lender takes the house and it becomes bank owned (REO).
Money left over belongs to you
If the house sells for more than the debt, the costs and any junior liens, the extra money is surplus and it belongs to the former owner. Each state has its own process to claim it, and much of it goes unclaimed. You can claim it yourself; you do not need to give a surplus recovery company a large cut.
Can the sale be stopped or undone?
Before the auction, a complete loss mitigation application sent more than 37 days before the sale, a bankruptcy filing, active military service, or paying the arrears where your state or loan allows it can stop the sale.
After the auction, most states give no right to buy the house back. Some do: a few states have a redemption period after the sale, and in judicial states the court often has to confirm the sale first. Your state page shows which rules apply.
You do not have to leave the day of the sale
The buyer still has to follow your state's eviction or possession process, which means notice and usually a court date. A tenant with a real lease is entitled to at least 90 days notice under the federal Protecting Tenants at Foreclosure Act.