Shame/conscience? Social norms? Adult supervision? Rules against sexual assault, stalking, etc?
This is a common fear conservatives have about trans people in bathrooms, but statistically they should have the opposite fear (trans people are more likely to be victims of SA, not perpetrators). When we allow people to use the bathrooms of their gender, we don't see opposite sex people faking trans-ness en masse to gawk at or assault people.
ETA: Perhaps this is different in different parts of the country, but my peers and I (Millennials) almost never got naked or used a public shower in our high school locker rooms. That is largely antiquated in my experience. Showers were technically available but never used, and quite gross and ancient. We would strip down to our underwear to change in PE but that's it. Perhaps other people my age or younger have had different experiences.