It could be that he has seen this somewhere TV .make sure no one is putting anything on a 4 year old shouldnt be watching in fact a child of any age, very often this is a learned behavior if you say nothing to him he may do it to others , so it is good that you spoke to him you did the right thing.If you are concerned speak to your Doctor .. ..
I'm a dad of 3 boys, and raising my 13 year old brother. My oldest son is 6 and has been caught doing the same thing with friends. Iv caught my bro aswell. Boys experimenting like that is normal. Don't make a big deal out of it. Most kids learn from other kids, and pass it on. Ur son was only experimenting. Don't punish, just talk to him. Once they realize this feels good, they tend to want to show their friends, even if they know its wrong. Don't look at it as him being molested, because he wasn't molested. I have caught my son quite a few times. Just know that it isn't a bad thing. Curiosity and experimenting is how children learn. Good luck!