As I said in another response, I think (at least partly) a contributing factor was the essentially limitless salary budget that VC funded startups and the FAANG companies had. You had software developers who could suddenly make more than doctors and lawyers and of course many of them sensibly acted in their own best interest but that left other employers saying "we're not going to invest in employees who are only going to turn around and leave for salaries we can't pay" and "if we have to pay those kind of salaries, we're not going to hire junior people we want experience."
Once a company hires and trains a junior, then they have a senior.. and they don't want to pay them a senior salary, but apparently other companies do.
The math remains simple: if you already have an employee on your payroll, how in the world are you not willing to pay them what they can get by switching at that point? That's literally just starving one's own investment.
The real issue is that the companies who were "training" the juniors were doing so only because they saw the juniors as a bargain given that they were initially willing to work for the lower wage. They just don't stay that way as they grow into the craft.