I would expect that old DDR4 machinery to end up somewhere else, still chugging along. Maybe someone buys the old production and keeps chugging low quality DDR4 or something.
To me, it sounds like that didn't happened. Fabs that were producing legacy DDR4 are still producing it, just selling it higher and surfing on the consumer price increase of DDR5. As DDR5 became more expensive, people looked to build old AM4 PCs with the older memory, and the market just raised the price so that option would also cost more. IMHO DDR4 price increase has nothing to do with production.