The clauses are negotiated between the players (and their agents, who are a wicked bunch, google Mino Raiola if you want) and the clubs. If a club wants to keep a player, the clubs interest is to set the clause as high as possible, to deter buyers, they call this blindar (you asked specifically about Spain, but the same is true in other countries too), which means to make bullet proof. But then the player insists in getting a higher salary (and a higher commission for the agent) and gets it. This is the way Messi ended up earning what he earns: he knew Barça wanted to keep him, so after many rounds of new contracts, with higher and higher clauses, he ended up earning so much that Barça could not afford to bullet proof Neymar to the same degree. Messi is earning about 50 million Euros per year after taxes, that means he is costing Barça 100 millions per year. Barça’s total budget is just ≈ ten times that!
Then it is true that the player can be bought for the amount set in the clause, but only if the player wants to go. Neymar wanted to go, it seems he had enough of playing second fiddle to Messi. May not have been a wise move, but his salary is even higher in Paris than it was in Barcelona. Rich boys problems…
Then there is the so called financial fair play rule: A club cannot run unlimited deficits forever and grants from a sponsor, country or oligarch don’t count as income. UEFA can ban a club that does not keep a minimum of equilibrium between expenditure and income from playing the interesting competitions (i.e.: Champions League). Paris Saint Germain could not afford to buy Mbappé after signing up Neymar, so they cheated‡: they took him on loan one year and bought him the next. That was borderline and was investigated by the UEFA bodies (who ruled in favour of PSG, money talks). They got a slap in the wrist: ts, ts, ts, do not do that again! Machester City has been investigated for overspending too and lost in the first instance two years ago, but won on appeal: they were almost banned from European competitions. Bayern München does overspend too in Germany: they buy the best German players over and over again. Thus their dominance in domestic competitions, and sometimes in Europe as well (Last time they won the Campions League: last year). In Germany you are either a supporter or you hate them.
Granted, the financial fair play rule is quite toothless, but it could bite nonetheless one day if UEFA wanted. It is a damocles sword that has been never used to the last consequence, but it could. Some day. (Yeah, I am a fan, and fans are dreamers). So far it has just been there to keep appearances, I know. But now that the rich clubs have so spectacularly belly flopped with the European Super League, UEFA migh show some resolve, as the clubs have overplayed their hands and their bluff has been called. They really shot themselves in the foot with that move.
‡ They all cheat. And bend the rules. And cook the books. And they are all very deep in debt. Covid may be the last nail in many a coffin.