During diligence a buyer may walk for any or no reason at all and if they do the diligence fee is all the Sellers get. Typically the earnest money deposit is paid the day diligence is over and this is put into a trust account. not given directly to the Seller. The Earnest money deposit can be tendered up front but there's really no reason to do so. Closing usually takes place within 10-15 days after the diligence expires. If you do buy the property the diligence fee is credited against the purchase price.
You should have had all of this explained to you buy your agent, when you first met them, if they did not do this I would suggest you are working with an inexperienced poorly trained agent. I hope you are working with a buyer broker and not counting on the sellers agent, allowing one agent to work both sides of a transaction is a terrible idea. There's clearly a conflict of interest (even though the state allows it) and the only person who has good representation in dual agent is the agent, the buyer and seller are essentially thrown under the bus and left to fend for themselves as best they can.