A sale is only completed once the notarized purchase contract has been signed. Until then, the seller can freely decide over their property.
Whether you will get the money back from the current tenant will ultimately be determined. It will depend on whether you can also provide proof of payment. Was there a contract regarding this?
You can assert claims for damages against the real estate agent in case of breach of secondary obligations. In particular, I see here the duties of disclosure, consultation, verification, and inquiry. However, since liability issues are generally decided on a case-by-case basis, you should consult a knowledgeable specialist lawyer.
An out-of-court settlement in the form of a mediation procedure between you and
- the real estate agent
- the tenant
- the seller
would be possible.