It's a dog thing. I had a female dog who'd roll in the smelliest stuff she could find if I gave her half a chance, she also loved to roll in mud. I had a male dog that did neither, the only thing he ever seemed to roll in was plain grass. The dog I have now is also a male, so far he's rolled in poo, he's rolled on a long dead, sun bleached, bone (I have a picture of that one), he's rolled on a dead worm, and he's rolled in stuff that he could obviously smell yet I couldn't. He's tried to roll on numerous other things including a dead toad. I no longer question why he rolls, I just do my utmost to prevent it, mainly because the brat hates a bath and some odors do not come out with a simple bath.
Sometimes it's easier said then done. Zody never rolls in his own poo, he usually does not roll in other dog's poo, but every once in awhile he finds a pile that causes something to click in his brain and causes him to think, "Ohhh boy!!! That smells wonderful! I'm gonna wear it and attract all the females!" Thankfully it's been over a year since I failed to stop him.
Cosmo has never rolled in poop but my grandparents dog rolls in anything disgusting she can find. Dead seagull carcasses, rotting fish, human poop even - anything! It's a nasty habit that I'm thankful Cosmo skipped out on.
It's really hard to train that kind of thing unless you have piles of **** (ha sorry) laying around for him to practice not rolling in. I'd suggest putting him on a leash when you can and when you can't just have some shampoo handy! Teaching leave it might also help if you have something that's of higher value than the poop like cool snacks or a favorite toy or if your dog just happens to listen really well, however Cosmo ignores the leave it command to EAT poop from other animals because that's apparently better than any snack I could conjure up.
Also would have to catch him before he gets into the poop for it to be effective.