An average dog's nose is anywhere between 10,000 to 100,000 times more sensitive than ours, and smelling each others' butts is just another example of chemical communication in the animal kingdom. It's like "speaking with chemicals," and that's how dogs ask about another dog's diet, gender, and emotional state.
Researchers studying the anal secretions of dogs and wild coyotes discovered that, next to their poppers, canines have pouches called anal sacs, which house the glands that secrete chemicals they use to get to know each other. Amines and acids are the primary compounds involved, and genetics and the state of their immune system can influence the aroma as well.
Dogs also have a secondary olfactory system in their nose called the Jacboson's organ, which is designed specifically for chemical communication. Its nerves lead right to the brain -- so the smell of poop doesn't overpower their sensitive senses.
Here's the video from the American Chemical Society's Reactions series:
"Bacon is to people as butts are to dogs."
Image: Gabriela Pinto via Flickr CC BY 2.0