There’s no privacy in a foxhole showers were rare and often communal, and toilets were open-hole latrines. Moreover, we forget - and are reminded by an essay in the book by a World War II Marine named Scotty Bowers - about the physical closeness that these fighting men lived with.
As for the candid nudity, there are too many of these pictures out there in the world for them to have been made on the sneak, and a World War II soldier who carried a camera (and quite a few did there’s a lot of downtime in a war zone, in between the scenes of mayhem) wouldn’t have been able to hide it easily. Some (like the pyramid pose below) were certainly set up for the picture. Well, chances are they weren’t creep shots. Bathing at a spring on Guadalcanal, 1943.