This happened to me on an investment property.
Chris
Sorry to hear that chrispy, mixture of a rookie error and some bad business practice.
There's one way you could avoid such an outcome.
First, get your pre-approval done before making an offer.
Then only ever make an offer by officially documenting it on a complete contract. Ensure that you have a deadline on the offer.
Even if you do the above there is nothing stopping an agent accepting another offer.
...An agent doesn't have to give you the right to another offer if yours is beaten and the vendor is happy... The only grey area is the deposit (i'm not sure which state you're in - different rules apply here).
...BUT, and here's the key, make sure you ask the agent for "first right of refusal" and get them to clarify this as a part of the sale method by email if you can.
At least this way, if your offer gets the property "on the market" you'll be in a position to raise your offer if there is another acceptable position on the table.
There is no deal until you've exchanged though, so until then, it's anyone's property... still it's not very nice of the agent to take another offer whilst you had money down