If it were me, I'd try to 'catch' him every so often and send him to use the toilet. Do not ask him if he needs to go, just send him. "It's time for a bathroom break" like it's a fact of life, once every couple hours (or more often, if necessary). If you are shopping, plan a trip to the toilet as a matter of course. My son hates using the bathroom in public and will tell me he doesn't have to go if I ask him, so I don't ask. I just tell him that it's time for a bathroom stop, and he usually does need to go. I'd also let the teacher know that if he has to use the toilet, she should just let him go immediately.
Some kids do get busy; some, I think, also go through phases of testing how long they can hold it because they don't want to stop what they are doing. And then accidents happen. I have seen this sort of pants-wetting a lot with children this age. Not every kid does it, but it isn't unique. I have more than one child in my life who, when they come to visit, I know I need to send them to the bathroom every couple hours.
I truly hope your little guy's health is fine and please know, it's not uncommon at this age!