There are two causes of this in an emergency:
Unfortunately, this makes the problem much worse, since there are some buyers who won't be affected by the emergency (either people who wind up not being in the path of the flood / hurricane / etc, or the predicted emergency situation didn't materialize). These buyers-who-didn't-need-to-stock-up are taking resources away from people who WERE affected by the emergency, and who actually legitimately need those scarce resouces.
Also, like the analogous bank runs, panic buying can be a self-fufilling prophesy — they can CAUSE an emergency even when none exists at all. Anticipatory emergencies become true emergencies.
Sadly, for a rational prepared individual, their best response is to participate in the problem, by trying to buy goods even sooner than the other buyers. This is a case where enlightened self-interest doesn't work — in this situation, the interests of the individual and the interests of society are very different.