I think I'm hearing three different questions here, about bed-wetting, accidents during the day at school, and using the potty at home but not at school (or do I have that backward – your description is rather ambiguous for me).
But kids go through many changes to their sleep cycles as they mature, and bed-wetting could be the result of his lapsing into heavier sleep cycles, or even incorporating "going to the bathroom" into his dreams (I've done that – fortunately have awakened dry and run to the bathroom every time so far…).
If it's a pattern change, it could last only a few weeks. Could go longer, so you might wish to put him in overnight diapers until he's had two weeks of dry again. He is still very young, and his physiology is still maturing, too. Bedwetting is very rarely within the control of the child.
At his age, it would be really hard to communicate with him in enough depth to know what his daytime issues are. It could be simple distraction. When he's sitting on the potty, he may not be noticing how full his bladder is, but only how much he wants to get back to his interrupted activity. Any kind of emotional tension can add pressure to the bladder and cause accidents, too. I would just stay positive and encouraging and appreciative of the times he succeeds. Many kids, especially boys, just don't have full control for another year or so. Even the ones who trained fairly early.
When I was little, moms prided themselves in getting their kids trained early, sometimes at 1.5 years. But my mom remembers that wetting accidents were extremely common among those children. Kids who lead their own potty learning often are not trained until 3 or later, but the ones I know have few accidents, and those are generally the result of failing to pay attention while playing, and waiting just a few seconds to long to make that dash.