Dogs snort when they are happy as a way of expressing themselves. They may get excited and jump around, so air is forced out of their snouts, creating snorting/grunting noises.