Earlier quoted context omitted.
Once they're trained up to a point where another company is willing to pay them more for a more senior position, you could give them a raise? Congrats! You trained a junior dev and they turned into a senior dev.
That's true but it also misses the point: A portion of the limited money-pool you could have used for their raise is already gone, spend in the extra costs (direct or opportunity) of the training period. There isn't much of a "raw mercenary economics" argument for training (which the MBA types prefer), you've got to talk about intangibles like loyalty, goodwill, social connections, etc.
Consider the costs associated with recruiting for a single role. You have to either advertise a role/filter out candidates or engage a recruiter (which costs time or money). You have to interview a number of people, taking time (money).
You then have to onboard that person, and choose a salary based on your limited knowledge about them. And even then you could still hire a lemon (although admittedly it could go the other way and you hire someone better than expeceted). You then have to wait for them to become productive in the new organisation.
You also have much better information about someone who has worked at your organisation for a longer period of time and can therefore tailor their salary better to their skills than for someone who you know nothing about.
Spending money on training is a predictable cost vs. an unknown future cost of hiring. And yes, people will also appreciate it as an intangible, which if you are 'mercenary' you can enumerate as a supplement to a certain amount of salary.