The term "scalded dog" originated when people used to cook, can, and preserve food outside. A dog could come into contact with spilled hot water or foodstuff and run from the pain. Dogs will run away from pain from bees or hot scalding water long after the pain causing entity is gone.
A dog that has been burned is a scalded dog and to run like a scalded dog is to run wildly from a pain causing experience.
The soldier ran like a scalded dog from the enemy forces.
The children ran like scalded dogs from the black bear.
The people ran like scalded dogs from the lava flow.
The escaped criminals ran like scalded dogs from the police.