The law mandated phone number portability in 2003. Everything else is buyer beware. Why is the answer not just "Don't get in a contract with Apple hardware if you don't want to be stuck playing Apple's ballgame?"
In the US I can just buy an iPhone from Apple with no hardware lock. So no.
That's the responsibility of the consumer to read the contract. You also can leave with a penalty.
Libertarianism is like the tide on hackernews, it's quite confusing