I'm not a child therapist so you probably should run it by kid experts. That said, it sounds very much like the intrusive thoughts of adults that are considered OCD if they get troubling enough.
Perhaps it is human nature to be drawn to whatever we have been told NOT to do. As Peter Pan put it, "It's good to be bad!" Put up a Don't Touch sign and people who wouldn't have cared less otherwise are suddenly impelled to cop a feel. My guess is that it is more about the forbidden than any issues with poop itself.
You might try chatting with him about that universal aspect of the human psyche. If he is prone to intrusive thoughts starting early helping him build a set of tools to understand and manage them will be a great asset.
Let me know how it goes.
tg
This is something totally different and possibly unrelated.
Some members have described various food compulsions and some have been pointed towards the eating disorder Pica.
Either way, it's always a good idea to run it past an expert. It's usually always easier to treat something earlier than later.
Good luck.