I volunteer with young children regularly and have had to do research and training into child psychology as a result. Everything below should match the general conciseness from child psychologists about child sexuality, I'm sorry I don't have time to provide links to appropriate references though.
As already said 'playing doctor' is a common behavior at this age and not usually something to worry about. Children are curious and want to know more about their bodies and the bodies of others, they also have little sense of privacy and thus see nothing wrong with sharing their bodies with someone they trust who asks. Thus it's only natural they are happy to agree to a deal of "I'll show you mine if you show me yours", as far as they are concerned "showing theirs' isn't a big deal and is hardly a hardship if that's all they need to do to satisfy their curiosities about the opposite sex.
I know some have claimed this situation is different then 'playing doctor' because they claim that a child shouldn't know mommies and daddies sometimes are naked together, but I do not agree with that sentiment. The kids were completely correct that parents are sometimes naked together after all, it's wrong to presume kids are so oblivious as to not pick up on obvious details about how the world works. It's entirely possible they figured out their own parents are sometimes naked together, for instance if they know you both change clothes in the same room it's not a giant leap to conclude that you must be naked in front of each other to do it. More likely they picked the idea up from television though, plenty of shows make allusions to adult sexuality and while those may not be shows you intend for your children to watch it's quite likely they overhear and see shows you, or even grandparents, babysitters, or other adults they visited, are watching and pick up details from them. They could also have picked it up from overhearing conversations or even jokes amongst adults. Finally even if you somehow kept your kids in a vacuum where they didn't see any adult content their peers likely have and may have said something to your kids about what they presumed adults did when alone. Children are far more attentive and pick up far more then most adults give them credit for! It's not at all inappropriate or unreasonable to presume a child would have deduced nudity happens amongst married individuals, it definitely doesn't require abuse to come to that conclusion.
I'll also point out that the kids didn't necessarily need to be certain that parents are naked to play this game. The real point was curiosity about the other sex, not the game itself. They would likely be happy to use whatever excuse is required to answer that curiosity. Just a vague idea that parents might be naked together is enough to justify a game both want to play anyways...
So the question is how should you handle this?
Ideally the best situation would have been to ask them to explain what they were playing and how they played it, without acting judgemental or concerned, when you first walked in. That would allow you to better understand their thoughts and intent that lead to them choosing to be naked together. It would have also allowed you to explain details about nudity, privacy, the differences between sexes, and consent in a way that would have flowed naturally from the situation. However, most of this discussion can still happen after the fact.
One of the first things you want to do is ask if both kids wanted to be naked, and if either kid felt forced to be naked. If either child felt in any way pressured or forced that would be a larger problem, requiring you to figure out how the child felt pressured, how severely the pressuring child imposed on the other child, and discuss why that was inappropriate etc etc. Luckily in these cases it's rare that either child has done much to pressure the other. Since kids this young generally don't mind being naked it likely didn't occur to them to be offended about being asked to get naked and so no pressure was required for them to agree to the game.
You would also want to explain nudity and privacy to them. You don't want to say being nude is always wrong or naughty, that risks causing them excessive guilt and also potentially making it harder for them to discuss nudity, their body, and sexuality with you later if they think even the most trivial aspect of sexuality is an 'always naughty' thing. That's a concern because it's important to put effort into making sure young children feel comfortable talking about their bodies now if you want them to feel comfortable talking to you as a teenage when they really need an adult they can trust to help them figure out things like how to get and use birth control, what activities is appropriate to do with a romantic partner, and even general relationship advice.
Instead you will want to talk to them about privacy and consent. Their private parts are private, things they usually want to keep to themselves. There may be times when it is good and okay to show those parts with other's, like when their parents are helping them take a bath or when a doctor needs to check those parts to make sure they are healthy, but they are still special parts they should try to keep private and probably shouldn't be showing to other children.
Along with this conversation you should start the discussion of consent. Tell them that their private parts are theirs and they get to decide when, and if, they allow other's to see or touch them. If anyone, child or adult, insists on seeing them or touching them and it makes the child uncomfortable they have the right to say no no matter what, even if it's an adult they trust or like! Most abused children are abused by someone they trust, so it's important they understand they can say no even to a trusted adult. Tell them if they aren't certain how they feel about someone asking to see their private parts they should come talk to you and you will help them figure it out and make sure the other person doesn't do anything that makes them uncomfortable.
Incidentally this conversation about consent should be reiterated in your actions. Children should always be taught that they should have to consent to other's doing things to their bodies. That means a child should feel free to ask not to be tickled, to refuse to give a hug or a kiss if they don't want to, to ask someone put them down etc. I know it's common for parents to pressure kids to give hugs to family members when they leave etc but if you really want to drive home the importance of consent then teach them it is their choice. The child should say goodbye to family, but if they don't desire physical contact when saying goodbye teach them they have that choice. Likewise if your child upsets another child by touching, hugging, or other physical contact when explaining why they were wrong make sure to point out the other child didn't consent to the contact and how it's wrong to touch someone's body without consent. Doing this will reinforce the importance of consent so children really understand that they have decisions about their own bodies. This doesn't just ensure they will tell you if someone tries to touch them inappropriately, which is in all honestly extremely unlikely to ever happen to them, but ensures as teens and young adults they feel comfortable setting limits and telling their partners what they are and are not comfortable with.
While you are speaking with your children about nudity it wouldn't hurt to ask the children if they have seen anyone else naked or been naked around other people. Do it in a casual manner, without implying there is anything wrong with it! This way if a child had been abused by an adult, or even another peer, you will find out about it.
In the highly unlikely event they tell you they had an abusive experience ask for enough details to prevent it from happening again and to get the appropriate consoling for the child. You should make sure not to act angry or upset at any point during such a conversation, even if you are understandably furious at whoever did such a thing, as the child will likely interpret any anger as meaning they did something wrong and should feel guilty. You shouldn't tell the children their experience is wrong or naughty, at most you can tell them that it's known that often children end up feeling hurt when they do something like that with grownups so grownups are taught to never do stuff with children. Saying it that way stresses that they did nothing wrong, that it was the grown up who broke the rules, and that the rules are only there to protect them not because sexuality itself is inherently wrong or their being involved in the experience means they did something wrong. If you believe actual abuse happened it's best to save explaining fully why it shouldn't have happened and how the adult who did it will be getting in trouble for an expert who is trained in handling abused children and knows best how to explain it safely if possible. That being said answer any and all questions the child has, answer them honestly, and make sure you don't imply there is anything wrong with discussing this with you. Obviously also tell them you love them and they did nothing wrong, you just want to make sure they aren't hurt by a grown up.
Finally since your children are showing an interest in the opposite sex this is a good time to explain the differences between the sexes. Us the correct terminology for their body pars, not some child safe euphemism, and express a willingness to answer any questions they may have. Knowing the proper terms for their body will also help protect a child form abuse by making it easier for them to explain if they feel someone did something inappropriate, and besides it's simply a good idea for a child to understand their body!
You may also want to consider some age appropriate discussion of the basics of sexuality and where babies came from. It's not that important that such a discussion happens at the same time your explaining the differences between the bodies, but it is a good idea to explain this stuff, at least up to the level the children are capable of understanding, early and his seems as good a time as any to do it. This is part of keeping the dialog open and ensuring children are comfortable talking with you about 'private' things so that hopefully they will still be willing to discuss important details as teenagers. Though I should stress there should not be one discussion about reproduction or sexuality, it's good to explain some basics now, and to keep having discussions and elaborating on these details as they grow older. I have a whole separate answer about how to discuss these details you can read if interested.