You can quit whenever you want. You just can't go do Pro Wrestling until your contract expires. Do you want to become an actor, or an accountant, or whatever? Your fine to do that. But as far as wrestling goes, you had a contract for X amount of time, you can't do it unless you get released from your existing contract
It's not that different than other sports leagues in North America. Ben Simmons didn't want to play Basketball for the 76ers, who he had a contract with. He could have retired and gotten out of the contract and gone to do anything else except play basketball in the NBA, but as he wanted to stay in the NBA, he had to wait till he was traded
When Brock Lesnar left WWE to try and make the NFL in 2004, that was fine. But when he tried to go to New Japan in 2006, WWE tried to stop it, and ended up losing the legal case. In 2021 there is a decent chance that case would have been ruled in favor of WWE- NJPW has US television, runs US live events, has a streaming service for english language viewers, etc- but back in 2006 when the only people watching NJPW in America were tape traders, it was a different story
I think there is a difference to other sports mainly in your equivalency being slightly off. The NBA is not equal to all of pro Basketball, it is one league of (perhaps a bit hypothetical) many. As I am more familiar with American Football I will use that as an example:
The NBA=NFL=WWE
Pro Basketball = Pro Football = Pro Wrestling
Pro Football = NFL, USFL, XFL, AFL, ...
Pro Wrestling = WWE, AEW, MLW, ROH, ...
NFL = Tampa Bay Buccaneers, Kansas City Chiefs, New England Patriots, Philadelphia Eagles, ...
WWE = Raw, Smackdown, NXT, ...
With that said, while the Philadelphia Eagles would not allow Jalen Hurts to sign with the New York Giants, while he is under contract to them, I don't know if they could stop him from playing for the Los Angeles Express of the USFL if he were to first retire from the NFL, thus more or less voiding his contract.
IIRC during NHL and/or NBA strikes/lockouts players also did play for other pro leagues in other countries.
But I think the main issue for WWE contracts perhaps being illegal is WWE pretending the Wrestlers are independent contractors but not allowing the wrestlers the freedom that should come with that status. As far as I can tell for the NBa and NFL the players are employees and not freelancers, as WWE would like to think the wrestlers are.