If you’ve already paid 40% you’ve agreed “tácitamente” to the contract stipulations albeit unbeknowst to yourself that is no legal excuse.
A different matter would be If you had only paid a deposit and nothing more and no POA granted.
I’m sorry, but in a contract almost anything may be agreed between the parties that enter to it just as long as it is legal according to Spanish and EU regulations.
If your lawyer agreed that in case you pull out you lose 30% of the purchase price, then that’s what you lose. And there is little that you can do.
I find it horribly abusive that clause, just goes to show how little your lawyer fought for your interests when drawing up the contract with the developer. He should have forwarned you of such a draconian clause.
You don’t lose anything taking the case to Málagas ICAM (Bar Council) and filing a complaint for abuse, it’s free for you. Better than nothing.