I remember pooping in my pants AND my diapers, but only when I was older - no real clear memories of the toddler days.
I used to, and I'm not sure why, try to 'hold it' for as long as I could. Usually I was doing something, building something, concentrating on something, etc. I was really into things like Mechano, electronics, etc even as a young kid and when I got going on that stuff I didn't want to quit. Or out playing.
Inevitably I'd end up messing my pants on the way to the bathroom. Sometimes quite a ways from the bathroom and once I remember, even right in front of the bathroom door. That time I thought I was going to make it, but mom was in the bathroom with the door locked and so I stood in the hallway and pooped right in my pants. She was not impressed with that.
Coming home with messy pants or going in my pants at home ended up the same way - getting cleaned up and put in a diaper for pooping my pants "like a baby". I wore diapers to bed every night for wetting, so I was used to the routine of being diapered but these instances were more like they were intended to emphasize how I was like a baby...so much more humiliating. And spending the rest of the day in diapers and plastic pants.
And anytime I was in diapers I used them when I had to go. I was diapered in the day sometimes to prevent accidents. Much more for wetting though.