This is a question dealing with culture. which has changed over time. Here is what I have witnessed in the US.
As a child in the early 1950s, boys until about 3 could go naked on public beaches. They were viewed as babies, their nudity not sexual in any way, and permitted. Girls rarely did, however. They wore bottoms, even when babies, but not tops.
At home I went naked in our backyard pool until I was about 8. But at the ocean or lake in public I had to wear swim trunks.
Some of my boy friends were still going naked as late as 12 or so in their own home pools, along with the rest of us boys when joining them, with their little sisters & girl friends watching. The big change came when we developed pubic hair. Then we had to wear something, we were becoming men. The rules for men were different, at least in the US. But not everywhere in the world.
It was just what we kids did at that time, with parental approval. And of course we were all naked at the Y swimming, and many school programs, but that was just all boys, or men. (The Y kept us segregated by age until around 15)
It was like males got a pass, but females did not. That no longer exists today in the US. Now NOBODY gets a pass, we're all equally neurotic conservative prudes. Doing the towel dance in male locker rooms like bashful girls. Again, a cultural decision, with some Right Wing politics and fundamental Christianity thrown in. It's only wrong, or right, when we arbitrarily say it is. And how we're raised & taught.