Whether or not you sanction playing doctor, make it clear to your child that young children and adults (or older children) should not touch each other's genitals. The only exceptions to this rule are: parents, who need to wash their child's genitals until he can do it himself; and doctors or other healthcare professionals, who sometimes need to examine children's genitals to check on a rash, for instance.
At four, your child also may begin showing his genitals to others in play. Sexual play occurs between children of the same sex as well as children of opposite sexes. It's very common for preschoolers to engage in genital touching, hugging, and kissing, often accompanied by lots of tickling and giggling. For you, this activity may seem inappropriate. But for your child, it's a playful yet perfectly logical way to explore his natural curiosity about gender differences. What could make the physical differences between boys and girls clearer than a game of, "I'll show you mine if you show me yours." (Oh, sure, you'll think, now he learns to take turns and share!)
As with all matters of preschool sexuality, try not to overreact to sex play. Just because your child and his friend are exploring their genitals is no reason to panic. In talking to your child about it, let him know that lots of children do that when they're little. Acknowledge—and even applaud—the children's curiosity about each other's bodies. If you want them to stop, however, tell both children that certain parts of our bodies are private. Then try to steer them toward a book that might satisfy their curiosity about their bodies.