At the beginning of story mode, the Undo Dog presses the Restart Rocket and it destroys Peach's castle and that's the whole plot of story mode. To use the Restart Rocket you have to press it for a couple of seconds, it's not instant. This means while everyone is screaming, "Oh no!", Mario could just run over and pick up the dog and it wouldn't destroy the castle.