D.T.
Get him to the doctor and DO NOT PUNISH him!! Or make him feel bad by being in diapers/pull-up. My son did the exact same thing and it sounds like your son may have the same thing. I forget the medical term (encoprisis?) Whatever... it's basically constant constipation. It's pretty common in 4-6 year old boys but most parents are clueless. Basically, a child gets constipated and can't get the stool out. A hard mass forms and loose stools steeps out around it and can not be controlled by the child. Over time, the muscles down there get stretch and the child loses feeling and honestly can't tell when he has to go. So it's fine for a few weeks and then *bam* accidents for a few days and then back to 'normal' but the cycle just gets worse and worse. The accidents don't look like constipation because they are loose.
The solution is quite easy but long-term... through diet or medicine make the child have 2-3 loose stools a day to keep "cleaned out". After 6-8 months the muscless will have returned to normal and feeling comes back and the child can control it. We tried diet with our 4 year old for a few months and it didn't work. He's now 5.5 and has been taking a dose of Miralax everyday for the past 4 months. He's been accident free for about 3 months now -- the longest he's gone. We'll continue until he's accident-free for 6 months then slowly wean off the Miralax following the doc's instructions. It's a powder OTC medicine you add into your child's drink (water, milk, juice, whatever) once or twice a day. It can take a few weeks to get the dose for your child right.
Other things you can do is restrict dairy and things like bananas that bind you up. Some kids are more sensitive to dairy, like my son... just 2 servings a day is too much for him. And feed lots of fiber (FiberOne bars taste great!) and things like raisins. Good luck!