When poop has been held repeatedly over months, the lower bowel stretches to hold more and the nerves that signal 'you need to go' become less sensitive. A child can then have a large amount of poop inside without feeling much at all. Softer poop higher up slips around the hard mass and leaks out, which is what parents see as skid marks, smells or accidents.
Because the child does not feel it, they are often as surprised and upset as you are. Many hide underwear or deny it, not out of defiance but out of shame. Reminders to 'just go to the toilet' do not help, because the urge they are supposed to act on is the very thing that has faded.
School intensifies the problem. Toilet breaks are scheduled, cubicles are public, and the fear of an accident in front of classmates makes holding feel like the safest option. By the afternoon the day's poop is added to what was already there.
This is why the plan at five and beyond centres on your pediatrician: the backed-up poop needs to be cleared and kept soft so the bowel can recover its size and signal. Home and school then make it possible for your child to use the toilet calmly and often enough. With all three in place, children improve, though it takes patience and the course is rarely a straight line.