One says that neither peace nor war action, nor daily business can succeed unless Ganesh has previously been worshipped.
This is not only true for human beings, but also for celestial creatures.
When Ganesh appeared, as the son born from Shiva's mind, the later decided that Ganesh should be worshipped by anybody wishing to get success. Even worshipping other gods would be inefficient if prior worship to Ganesh had not been achieved.
Thus, when Shiva left to fight the demons of the Tripura city, he forgot his own rule and rushed to the battle. However, when he embarked on his carriage, the wheel peg broke and the car was stopped.
Abashed that such an accident could happen to him, Shiva realized that he had forgotten to pray Ganesh before his departure, and this was the cause of the obstacle... Thus, he worshipped his son's name and could proceed to the Tripurâtanka battle which he won successfully.