The market alone doesn’t work well with things like training that had feedback loops of several years. In German there is the term “Schweinezyklus”. It goes like this:

* companies complain about lack of trained workers

* more people start training

* after a few years companies complain about too many workers and don’t hire them

* people stop training

* companies complain about lack of trained workers

I was part of this in the 90s in mechanical engineering. When I started studying the job market was great. When I finished there were no jobs. Luckily I could jump to programming.

I think we are seeing the same with CS now. Too many people jumped into it.

Predicting the future is indeed famously difficult, which is why even markets have a hard time with forecasting and responding to demand years into the future. I don't think such over corrections are a market failure, just a lack of omniscience.