There's a pretty prevalent model for Risk Communication that compares the actual hazard (how bad something will be if it happens) against a person's outrage (how bad a person thinks a thing will be).
When the prevalent authority communicates risk in a way that lowers a person's outrage too low you can get inaction (like a president saying "don't worry" or “I think that whole situation will start working out.")
When the prevalent authority communicates risk in a way that raises a person's outrage (like surprising a population who were told to ignore a situation by then banning travel, closing borders and telling people we don't have testing capacity) you can get very strong reactions.
It's good when outrage matches hazard, that's where we want to be. But when hazard is, say, in the middle, and outrage is raised above that, you can end up with people feeling like they desperately need things.
At this point, they throw whatever money they have to at the things in order to mitigate their perceived hazard, and that's where opportunists and gougers come in. These people aren't acting rationally (they're perceiving a higher hazard than is real) and are vulnerable to ignoring market conditions in that "a free market works when both parties have perfect knowledge" sort of way.
So understanding this, we take actions that kneecap the unrestricted free market, because it doesn't have compassion and we want to be compassionate toward our neighbors that got too freaked out for their own good.
No one should try and take advantage of a vulnerable party, and it's a good thing to have safeguards against that.