Pooping asks for a relaxed body and a sense of safety. Daytime is busy, public and full of expectations about the potty. Bedtime, by contrast, is slow, private and ends with a familiar pull-up going on. For a child who is even a little wary of pooping, the choice is obvious: wait.
Many children are not deciding this consciously. The urge comes and goes during the day, and a child absorbed in play or unsure of the toilet simply lets it pass. By evening the poop is bigger, and the pull-up is where it finally feels fine to go.
There is sometimes a sleep element too. Children relax deeply when they lie down, and a poop that has been waiting all day can come once the body lets go. Pooping in sleep is unusual and worth mentioning to your pediatrician, because it can signal a bowel that is quite full.
The pattern often starts after a painful poop or a stressful potty-training push. The pull-up became the only place pooping did not hurt or did not involve a fight. Fixing the pattern means making other places feel that safe.