It could be regression but little boys are notorious for delaying pee and poop. They have all manner of reasons for doing it - or not doing it.
Underlying constipation could be at the root of your son's issue because it puts a lot of pressure on the bladder and confuses all the signals that we take for granted. If he is constipated, he simply may not be able to make sense of what he is feeling and he's hit by surprise with an accident.
Definitely hold off on the criticism and chastizing for now. For this issue, only respond to behavior you want him to keep.
You can also consult with your doctor about treatment options and the possibility of taking him to a see a urologist. We did just that for one of my sons and the urologist gave us a protocol for releasing the constipation and for helping him to maintain a healthy bowel. So far so good.