This is one of the pitfalls of Dual Agency. The Broker is now torn between satisfying two clients. Unfortunately, you may need to contact an attorney.
This is not the end of the road. I would start with having a lawyer contact the agent to request your earnest money on your behalf. If you are legally entitled to the money, one phone call can do the trick.
Hope it works out for you.
If the agent is acting as a dual agent, then they need to explain to the seller that they need to release the earnest money.
If the seller won't release the money, you may need to contact an attorney.