Young children are naturally curious about their bodies. Part of their development is learning the differences between boys and girls. They may explore these differences by playing the "doctor game" where they take their clothes off in order to show their private parts.
When parents stumble into a situation like this, it can be easy to get upset. Amy Lang from Birds + Bees + Kids recommends calmly addressing the situation, asking the children to put their clothes back on and directing them to another activity. It might sound like this: "I see that you are looking at each other's privates. I feel uncomfortable when I see that happen. We'll talk about this later. Why don't you put your clothes on and we'll go outside and play."
Lang explains that this type of sex play is normal and healthy as long as it is spontaneous, mutual and good humored. The time to be concerned is if the behavior is adult-like, aggressive, recurring or involves secrecy or being sneaky.