I understand your frustration, especially if you were in escrow, and already paid for an inspection and appraisal. Banks often have their own document(s) stating that they can sell the property to a higher bidder, even when in escrow; I've even seen this on bank-owned properties, although it never happened to any of my buyers.
Next time you sign any bank contracts on an offer you submit, read every line carefully, and make notes of the terms and dates. If you read something that doesn't sit right with you or make sense, ask your agent to clarify it. Sometimes it's not even apparent to the listing agent, and they'll say, "Oh, that never happens," but now you know it can. So, just be aware in the future.
As Oscar said, read each page of your contract very carefully, for any verbiage allowing this. If you don't see anything stating the bank can do this, then speak with an attorney, especially if your contingencies were "effectively" removed, which is common wording with some banks. And, as Jason said, some short sales in escrow actually end up foreclosing, and being listed again as bank owned - for a lower price! It happened to one of my buyers too, but he know it was a possibility.
Sometimes short sales don't proceed as logically as you think they should.
All the best to you on this, and in your next home search!