I imagine it must have been upsetting to hear that your child was engaging in this kind of touching, but there are a couple of things to keep in mind.
Sexual play or "playing doctor", is very common between the ages of 3-6. Children at this age have begun to discover the physical differences between boys and girls, and they are naturally fascinated with the different ways in which our bodies work (e.g., Boys pee standing up, girls pee sitting down). This interest inspires many children to engage in "show-and-tell", comparing and contrasting body parts, and playing doctor (the doctor's office is one of the few places they have dressed down in front of someone not in the family).
In most circumstances the most appropriate way to handle this kind of play is to stay calm and matter-of-factly communicate the limits for this kind of behavior. Explain that certain parts of the body are private (the parts of the body that the bathing suit covers), which means that they should not be shown to anyone except under special circumstances (e.g., the doctor's office). By remaining calm, you can avoid shaming or embarrassing your child. This is an opportunity to begin their sex education, explaining to them that their body is private, only to be shared with certain people, and not dirty.
Now, if this kind of behavior has happened many times, and your child has been told about appropriate and inappropriate touching, and they still continue to touch other children, you may want to speak with your pediatrician and/or a mental health professional. Some children who have been exposed to adult sexual content become preoccupied with sexually charged situations because they are trying to manage their anxiety about the exposure. The brain of a young child is not developed and mature enough to make sense of the sexual images and information, their bodies become charged, and they can act these feelings out on other children.
I have included a link to an article below that examines normative sexual development for five-year-old children.