I’ve posted a version of my response below in another similar thread, but am posting it here again as it’s relevant:
I have been a regular at a gym on a university campus for the past 3 years and I’m happy to report that, at least at this school, young (presumably mostly straight) guys aren’t afraid to get naked in the locker room. It was only last summer that they set up dividers in the showers, which had been communal since the gym was built in the late 70s. I’ve seen some both the largest and smallest dicks in my life in that shower, and you have the full gamut of everything: cut, uncut, shaved, natural, girthy, slender, micropenis, huge balls, etc. I’ve seen a 5’5 guy packing more meat than 6’7+ Division I basketball players.
I think a lot of different factors are at play, with the setting and clientele being two prominent factors. At 30, I am one of the older patrons at the time I go (every morning between 7-9 am, though there are a few much older guys here and there). During this time of morning, we’re a small crowd (about 25 guys) and we all know/of each other as regulars. For myself included, I think it’s helpful to know that the guys you see in the locker room are also the same ones putting in work on the gym floor. I’ll be the first to admit that I also enjoy checking out other guys’ bodies, but we can all tell when someone is just a shower/locker room hawk who comes in for the sole purpose of checking out other guys and maybe looking for action: You never saw them actually working out. I also avoid changing around these types.
There have been plenty of guys who would be extremely modest in the locker room, and then after a week or so of noticing me moving about naked, changing sans towel, and sitting in the sauna in the buff, they would start to follow suit. I’ve even seen guys come to the sauna in their underwear then once they saw me there naked, they would go back to their lockers, take them off, and come and sit completely naked with me. Since they put up the shower stalls, I’d say a solid 40% of the guys shower with their curtains open (myself included), and when there are groups of guys who are friends or teammates and they’re chatting, the number is even higher.
More than just being naked for the sake of being naked, I enjoy showing off my body because I work hard to improve it. I can’t explain everyone else’s reasoning, but imagine that a lot of other guys follow the same logic. And I “group think” (or in this case, activity) is a real thing, so I think that if there are enough or even a majority of guys doing it, then others would follow suit.
Also, it’s important to remember that my generation was raised by the generation before us and the values they imparted. So the real question about where this prudishness and fear of nudity became more prominent needs to be directed to the late baby boomers and early gen X-ers who raised us, not millennials and gen Z-ers.