Even in older kids and kids that are potty trained already, accidents WILL happen. Childhood.
I do not know of any child, that is 100% free of accidents.
Things happen, being sick, etc., that can cause momentary 'mistakes.'
Put it this way: my daughter, per ALL of her Teachers from Preschool/Kindergarten/1st Grade, all said, that accidents in children at these ages, do occur. Even on field trips and at night.
And, night-time dryness is not something that is BIOLOGICALLY attained, until even 7 years old. Normal.
-My daughter for example, was in night-time diapers even when she was 5 years old. She still had accidents. Normal. No biggie.
And even at 7 years old, she would still have the occasional night-time accidents. No biggie.
I just use with my kids, waterproof bed pads, under them. So clean up is super easy. The sheets do not get soiled.
-My son is 4, and he still wears night-time diapers for naps and night time. No biggie. He IS potty trained, but is still wet when sleeping. He does not get 'confused' about it nor wearing a diaper when sleeping. He knows, because I explain to him, that his body is not ready yet, for being dry when he sleeps.
Also, kids do not have complete impulse-control. Or, they may 'think' they can hold their bladder longer, but cannot. Hence, they are still learning how to 'predict' if they have to use the bathroom NOW, or can hold it. Hence, accidents. Or, them peeing by accident on the bathroom floor, before they actually get on the toilet. Not fast enough.
Of course, they know its not the 'right' thing to do.
But, their physiological ability, is NOT congruent with their thoughts. It is not totally coordinated, yet.
Scolding will not improve it.
Not saying you do this. Just an example.
Your son is normal. He is 4.
Even a 5 year old will have accidents. Or miscalculating 'when' they REALLY need to use the bathroom.
In my daughter's Karate class, there are a couple of 5-6 year olds. They, have accidents. Even if they are already potty trained.
The Sensei teachers, make no big deal of it. Because, these children are still young. And they 'think' they can hold it, but can't. The parents don't make a big deal of it, either.