You could talk to his pediatrician, without your son present, for advice on ways to handle the situation and to put your mind at ease.
Some children discover themselves far earlier than others, BUT you do have to put an instant stop to him attacking others. Remove him from the situation, get down on his level and make sure he has your full attention and let him know that it is not OK to touch other peoples private parts (list everything that is off limits) and tell him to let you know if anyone ever tries to touch his. Then, everytime after that, remove him from the situation, tell him it is wrong, and give him a time out. Try not to tell him that touching himself is wrong or bad, just make sure he knows he can only do it in his room by himself, he can not do it if anyone can see him.
Good luck