I think the reason is simple: once the junior dev is trained, they will leave. To be clear, I am not saying that they are obliged to stay in the company that trained them or being ungrateful in any sense, I am simply implying this is a common outcome from such training. In software industry, the first job switch in 2 years seems pretty common and reasonable, and the dev by that time would be able to strike a better j…
A friend of mine runs a web dev shop and I have seen him train at least six people from zero-to-pro (very smart, fast learners with a math background) and what you described is exactly what happens. Once they become medium/advanced-level proficient they often quit and move on to other, bigger companies. If there was some formal, or informal understanding that candidates "trained on the job" would stay for a few years…
After two years, you’re essentially a mid-level engineer and the money you can command is way more than what a junior developer with two annual “raises” is typically paid.