Legal? Sure. Why not? Now, depending on their listing agreement, the sellers may owe a commission to their agent because (not knowing the details of your offer, specifically any contingencies) their agent produced a ready, willing, and able buyer. But, while that could be some pressure on them, it doesn't mean they have to sell...or that they have to sell to you.
Probably what happened is that the sellers got seller's remorse, especially if your offer came in very quickly after the property was listed. ("Honey, we probably could have gotten more for our house...") So they decided to bump the price up and see if there's any activity at the higher level.
However, did your offer have an expiration date? You definitely don't want their agent "shopping" your offer, in effect creating an auction. Your offer should have already expired (and so the sellers couldn't still be considering). An expiration puts pressure on the sellers to decide.
And let this be a negotiating lesson, especially in a soft market. Whenever someone offers to pay full price, the seller will think "I could have gotten more." That creates instant remorse. Always negotiate on some items. Price. Terms. Something. Something that the seller can counter with. It'll make them feel a lot better.
And what's your Realtor's take on the situation? And your Realtor should contact the seller's agent for updates and clarification.
Hope that helps.