This typically happens at 3-4 years old.
It is common.
The child is not being "naughty."
They just do not have astute nor accurate predictions... about their body/bladder/how long they can hold it.
ALL of my daughter's Teachers, from Preschool to Kindergarten to 1st Grade... ALL unanimously said, that kids these ages have accidents. No biggie and they do NOT make a big deal of it. Therefore, in these grade levels, the parents are asked to bring in extra clothing for their child, to be kept in school. And in fact, at my kids' school, even the Health Room has extra clothing for the kids, who may have accidents. Clean clothing.
There is no point in punishing for this.
My daughter when she was that age, had that happen too. It was her age and being "busy" but also, that is when we had a 2nd child. So there was also "stress" for her, as well. You gotta remember, that a kid this age is not fully developed yet, emotionally, either. My daughter had been potty trained since she was 2 years old...but at 3.5 years old, she started to have accidents... or holding it too long etc.
They just do not "estimate" very well yet... about how long they can hold it.
Kids have accidents. It is childhood.
No matter how long the child was toilet trained, they have accidents. And then there is night-time dryness, which is a whole other different timeline. Night time dryness, does not occur until even 7 years old. Because the body is still developing and maturing. Even at 7 years old, my daughter had accidents, at night. My son is 5 and he still has accidents and is wet at night and needs night diapers.
All, normal.