Does earnest money go to the seller?
Not directly, in most deals. Earnest money usually sits with a neutral third party, such as an escrow company, title company, broker trust account or attorney. At closing it is credited to the buyer and becomes part of the money the seller is paid for the house.
The seller keeps it outright only when the buyer defaults, meaning the buyer walks away without a reason the contract allows. Even then, the escrow holder generally waits for both sides to sign a release or for a ruling before paying anyone.
There are exceptions. Some builder contracts let the builder use the deposit for construction before closing. Some states also use a separate due diligence fee that goes to the seller right away. The guide on who holds earnest money explains how the money is kept until closing.