> [...] once trained, they will leave to some competitor who can pay more.
That comes up a lot, but it's not true. That employer ALSO has the ability to hire someone that was trained elsewhere and pay a premium-- it goes both ways. Moreover, it is not the case that "once trained" the employee can easily find work elsewhere. Employers who are willing to pay a premium for skill want _experience_ and not just a training certificate (especially an in-house one of possibly dubious value). There's a lot more to do for the employee after they're trained and the best way to do it is to stay and practice the newly learned skills.
> [...] couldn't the training be offered
> [...] such as if the worker leaves before
> X months (or years) some % of that quantity
> must be given back?
There are places that do that. It's a bit draconian and you usually hear about it Asian countries. Much more practical to just eat the cost of an occasional early quitter-- not like it's going to sink the company.