It's not a legal agreement but a gentleman's agreement. They may still freely leave for whatever reason, especially if they were not treated well or treated like a slave (ie employer broke the agreement), but if all goes well it's some assurance, or at least a communication so everyone is on the same page. And usually being on the same stage and starting out with such trust sets the stage nicely for a good, trust-based safe working relationship
The juniors you train today someone will poach, surely, as you'll poach someone else's, and it levels out.
Fast forward half a decade forward, and there's no juniors or mediors to onboard, no-one to have gemeric expertise that can be fine tuned to your product.
What I suspect is going to happen is something like the regional pilot situation, where one toils for pennies at lower levels and then gets to comfortable compensation numbers 10-15 years later.
I have yet to hear of a productive software development shop successfully reducing staff count due to LLM usage.
Millionaires, at best. :p