There are a number of explanations for why dogs roll in the excrement of other animals, animal carcasses, or other things that smell strongly. The most common explanation by ethologists is that the dogs are trying to mask their own scent. It's one of those protective mechanisms hard-wired into the dog by its DNA. After all, dogs are only 15-20 thousand years separated from their wolf ancestors, and it makes excellent survival sense to hide one's scent when in the neighborhood of either predators or prey. I have two dogs, and I've had to bathe them more times than I want to count after a little excursion into the woods around our home.