Back when dogs were wild and roaming the plains instead of riding around inside of tiny purses, predators could find a dog's den by detecting the smell of poop, specifically the kind left by defenseless, tasty puppies. Puppy feces has a distinct smell (you puppy owners know this!) because of the high milk content, making it the shit equivalent of a Swiss delicacy. So, to clean up the evidence and keep predators away, mom would eat it. We don't know why she doesn't just bury it, but we're not here to judge.
Only imagine that stick is poop.
Anyway, this tradition carries on even for dogs that had been living in the comfort of human homes for generations. Tradition just works like that sometimes, you don't know why you and your buddies high-five when you're celebrating something, you just do it because that's what people do. You would think that at some point you'd reevaluate it if instead of slapping hands you were fucking eating your own shit. But again, they're dogs.