There’s the story of a manager who starts booking expensive training courses for his team, and another manager says, “but what if you spend all this money on training and they take their new qualifications and leave the company?” to which the first manager replies, “and what if we don’t give them any training, they stay low-skilled, and they stay?”
If it's really expensive training then it's not uncommon to mandate that the employee must stay, say, 2 years afterwards or repay the training's cost pro-rata.
In any case, people leave because they are unsatisfied and/or underpaid so if the company has that covered attrition will be low.
If employees have choice for denying this training, then most employees will never be part of this. If not, I think it is morally wrong to force longer stay and I would start looking for another job if I am in this situation.
Those kind of deals (and trainings) are not offered to everyone. Either the company has such program opened only to the best employees with high potential or an employee comes forward and asks, and again only the best performers may get a 'yes'.
This is a win-win deal with absolutely nothing 'morally wrong'.
I know companies in different sectors who have mandatory expensive training with clause that the employee has to give money back to the company if they leave within 2 years.
They might try, but people with useful rare skills can get away with asking for more money during job hunts, and that's not always the case (or at least not so soon) for existing employees.
(I'm hypothesising wildly, this isn't necessarily accurate).
tbh I hate this approach of up-skilling / free trainings, all they are really after with this is squeezing every last bit of juice out of you so they can continue to consolidate job roles and make you do more with less, instead of hiring SME's for specific things, they have a jack of all trades working on an endless amount of items that use to require a team of 10+ people to do. Especially in tech roles.