I don't know about explaining sex to a young child, but my daughter who is now 3 1/2 has always been fond of her genitals anytime she is naked.
I have found her touching herself and have always told her that her vagina is special to her and only SHE can touch it. BUT she has to do it in private.
Most of the time she does this in her play room while watching shows, I personally think it is a boredom thing. But I have always taught her to cover herself with a blanket or go to her room.
I think you should explain the difference between a boy and girl, use proper names for genitals and remind your child that touching is OK but only to be done by HIM/HER and always in privacy and then you have to remember to honor that privacy, by knocking on the door and giving the child a moment to regroup. however you want to say.
Masturbation is very normal and this is a learning process, where children are learning about their bodies and we as parents should make it as normal and OK as possible as to not cause any kind of self body image problems in the future. This is also a great way to talk about stranger danger and how it is VERY wrong for anyone to touch your child inappropriately, no matter what that person may say.
Hope this sheds some light Tammy