Accidents often happen because children do not want to stop playing. Children need to be reminded to stop their play to go to the bathroom. Accidents sometimes happen because of extra stress in a child's life. Bedtime is an especially important time for closeness and comfort. The accidents will probably stop on their own, as little by little, children adjust to the stresses.
Many children already feel bad when they have had a toilet accident.
Punishment could make children feel too ashamed to try next time. It could help to talk with a child-care provider or other parents for more ideas to try. Your child might have an infection or other physical problem. The doctor could give you some other ideas that may help. Family Communications is the producer of Mister Rogers' Neighborhood seen daily on PBS, dealing with themes important in the lives of children and families.