That's true, but by the same token, it's also true the world is mostly made of shit companies.
Companies are just following local gradient they perceive. Some can afford to train people - mostly ones without much competition (and/or big enough to have a buffer against competitors and market fluctuations). Most can't (or at least think they can't), and so don't.
There's a saying attributed to the late founder of an IT corporation in my country - "any specialist can be replaced by a finite amount of students". This may not be true in a useful fashion[0], but the sentiment feels accurate. The market seems to be showing that for most of the industry, fresh junior coders are at the equilibrium: skilled enough to do the job[1], plentiful enough to be cheap to hire - cheap enough that it makes more sense to push seniors away from coding and towards management (er, "mentoring new juniors").
In short, for the past decade or more, the market was strongly suggesting that it's cheaper to perpetually hire and replace juniors than to train up and retain expertise.
--
[0] - However, with LLMs getting better than students, this has an interesting and more worrying corollary: "any specialist can be replaced by a finite amount of LLM spend".
[1] - However shitty. But, as I said, most software is throwaway. Self-reinforcing loop? Probably. But it is what it is.