Imagine something hurt or startled you badly once, and now you feel the first signs of it starting again. Your body tightens before you have time to think. That is close to what a scared child feels when the urge to poop arrives.
For a toddler or preschooler, the trigger is often a hard poop that stung, but it can also be a flush that roared under them, a fear of falling into the toilet, a rushed trip to a strange bathroom, or a tummy bug that made pooping feel out of control. Some children are unsettled by the idea of something leaving their body at all.
Young children cannot reason their way out of fear. Telling them it will be fine does not reach the part of them that is bracing. What reaches it is experience: calm adults, a bathroom that feels safe, poops that come out soft, and no one rushing them. Each comfortable poop is a small piece of evidence that the urge is safe again.
This is why the order matters. Comfort and safety come first, and the potty skills come back once the fear has room to shrink.