For some situations there might be a valid reason for some of the restrictions but what's likely is that such "valid reason" was quickly extended to everyone except those with bargaining power.
One situation could be that there's few companies with tech in which skills are specialist on-the-job learned sort but are also transferable to competing company. (though similar fear could be assumed for transfer of IP or clients). If the new hire learned these skills on the company dime and then soon jumped to the competitor because just not liking the place or got better offers (just when they were about to actually be valuable to the company where they learned the specialist stuff), I could understand if the employer would have serious issues there.
Now how would the right balance here be implemented in unambiguous manner? To avoid things getting too complicated, perhaps the "test" should be related to what you presented in your CV and what the employer presented in their official job add. If the job you end up is something not in your CV already and is found listed in other peoples CV's, then you probably learned it on the job. In that case the employer should have "dibs" on you actually staying there for some reasonable time beyond just learning the skill. What that would be, no comment.
EDIT: On the other hand, if the employee begins to feel "trapped", that surely can't be good for the company in the long term either. I'm kind of thinking that the "dibs"/non-compete length should be somehow related to how much the company actually invested in you - eg. if it took you x amount of time to get up to speed and perhaps some other person was not doing what they usually do for y amount of time, then these might factor into how long you should be expected at minimum to stay there. I'm just not sure if having this sort of restrictions is overall a positive because if the atmosphere gets poisoned/resentful or whatever due to someone feeling trapped, that could be really bad in long term for the company.
This sounds a lot like a Contract. My company has what they call "At will employment". They say it means they can fire me, and I can quit, at any time.
But if they wanted to ensure that I don't get valuable on the job training and then leave, a contract seems like the way to ensure that. (I am a programmer, not a lawyer, so there may be a better term for "employment contract".)
A contract has the benefit of not being as hidden/shady. If I don't want to get locked in, I can just not take the job.
Hidden non-poaching agreements are evil. And when done by several large companies, bring down the wage of the whole industry.
Having something like a 2 year work contract when you get hired is going to make the job less desirable to candidates. But that is the trade-off if you can't keep your employees at market level of pay and work environment.