That is because the same happens every year. Even a bad AI or child (using OPs example) can plan for that. But when it comes to events that happen sporadically markets seem to have issues where most sane adults would be able to handle it.
It's probably a sane choice for most products to -not- prepare for very rare disasters like a hundred year pandemic. After all, markets optimize for profit, not convenience or safety.
These shortages will all smooth out relatively soon. It can cost a lot of money to be prepared for everything.
Sometimes the most efficient option is not the safest or happiest or winning option. If our prime goal was cheapest lumber 99% of the time, then sure a traditional market is very good at that. I would happily pay for 1% more expensive lumber all the time to avoid paying for 1000% more expensive lumber (read: not being able to buy lumber) when I really need it.
Markets allow the type of behavior that we see “sane” adults engaging in by design. So if you update the design or the rules of the market, you will observe different behavior from its participants.