Have you talked with him?
ALL of my Daughter's teachers, from Preschool to Kindergarten and 1st grade, ALL said that kids these ages have accidents. Still.
Kids have accidents. Even if potty trained. Childhood.
Or, sometimes it can be due to stress or changes in the family or household.
Unless he has a medical problem, it is probably a phase.
My daughter was potty trained from 2.5 years old. Then in Preschool at about 3.5 years old, she started having accidents. The Teacher made no big deal of it, we did not either, my daughter didn't know why, and it was a phase. It also had to do with my having had a 2nd child at the time. ie: stress for her and life changes.
She also, 'thought' she could hold her organs longer, but could not. Kids this age, often 'think' they can hold their bowels/bladder longer... but cannot. Because- they cannot yet, 'predict' how long they can hold it. Then it is too late. It is because their organs/brain/nerve connections, are still developing. It is not fully developed, yet. Even if potty trained.
I would not scold for it. Not saying you are.
But try to see if it is emotion based, or simply his organs is not developed enough yet for him to be exact or he is waiting too long.
Also, see if he has a medical problem.
Urinary infections, or "Encopresis" (which is an involuntary leaking of poop) due to things like constipation.