Although nobody knows for sure why dogs like to roll in feces or dead animal carcasses, there are a couple of theories. Because dogs are descended from wolves, which are natural predators, it is thought that rolling in such foul-smelling substances helps a dog mask its own natural scent, thereby making him a more effective hunter. Another theory holds that this behavior serves as a form of communication, helping one dog let the others know where he has been. 
In addition, while we may like the sweet smell of a freshly bathed dog, the dogs are often not fond of the smell. It is quite common for dogs to engage in this rolling behavior directly following a bath, possibly in an effort to eliminate the perfume scent of the shampoo. 
To keep this rolling-in-poop behavior to a minimum, clean up your dog's excrement immediately, and keep him on a short leash when walking in areas where he may encounter other dogs' droppings. Discourage the rolling behavior by associating it with an unpleasant experience, such as a squirt from a water bottle or a loud noise.  You can also teach your dog the "leave it" command, which teaches him to stop paying attention to an environmental distraction.