The answer is a conditional "no":
Did the party you signed the contract with have authority to sign the contract?
In other words,
had that authority been given to a real estate agent?
If the party had no authority,
then the best you can hope for is your earnest money returned from the party that you gave it to.
Assuming the party that signed the contract had the authority to do so:
Were there any conditions in the contract that allowed them to sell the house to someone else?
Most common would be a time-limitation.
to come to an agreement,
typically because of a contingency the buyer may have regarding the sale of their previous home.
The seller cannot be reasonalby expected to wait forever for buyer to sell their previous residence,
thus a time limitationo.
In any case,
you should be entitled to receive your earnest money back.