Not to justify it, but for the businesses involved, it is not profitable enough to build the fabs ahead of time. It's also risky. If the demand didn't arrive as expected, they would make a huge loss. Memory is more profitable when you can rely on everyone being risk-averse. Nobody builds the fabs ahead of time; they can let pricing spike, and then use that money to build fabs. In the meantime, high memory prices make them a ton of money.
Morally, I think doing this intentionally is wrong. At the very least, it's disrespectful to customers and consumers. It creates hardship for many people in the name of profit, with profit being the sole driving force.
Personally, I am sick of seeing the same problems every few years because of an intentional lack of forward planning. To investors and memory companies, these problems are a sign that the system is working as intended. Everyone else just has to put up with it. Higher electronics costs to feed the greed.
So many people are already priced out of the PC gaming hobby. It sickens me to see things get worse.