I think a lot of little kids (especially boys for some reason) can't get the hang of when to poop! The urge to move your bowels is a different feeling from having to pee and they are doing it before they even realize it!
My son wasn't as consistent with it as yours, but I found hidden poopy underpants a few times- he knew he wasn't supposed to, but couldn't quite control it until it was too late!
The one thing that really helped, silly as it sounds, were regular reminders to poop! If you need to, put him on a little poopy schedule about an hour after he eats, feed him something fibery, and set him on the potty. Remind him that he might need to make a poopy and that he needs to try and do that, as well as urinate.
Give him things to do while on the potty= read to him, a little drawing board, anything to distract him so he sits there long enough to make it happen.
Also, make sure his stools are soft enough- if he is having hard poops, it make hurt some to pass them, and then he will 'hold it' as long as possible- my son once did this and gave himself a stomach cramp! Lots of fiber, fruits and veggies, and if you need it, a gentle, child-safe laxative can all help.
Good luck! He'll get the hang of it :)