
different material, underwear can be slightly see through or not cover as much and is generally a bit thinner, but thats just the reason you dont wear underwear as swimsuits and vice versa
its mostly just different settings, as a man, you wouldnt just go outside in the city while shirtless, would you? but in the beach its expected, because youre getting in the water
its like how we wear different clothes to different places and circumstances, beaches, work, parties, weddings, funerals, hiking, school, home, theres different attires that would be considered "normal" in all of those

Some underwear are see through, but you can easily find underwear that cover just as much as swim wear (the material is obviously different because one need to dry more easily). But being shocked by undies and not swim wear is definitly cultural and not logical.
Also, this is not a question of what's proper or not. It's some pieces of clothe are seen as lewd while others are not, when objectively speaking they look exactly the same. (Coming to work in swim trunks is not lewd, it's just weird and probably forbidden).
Yk what i had the Exact same train of thought when i was 10 lol
Whats the difference bw swim wear and underwear, they basically cover just as much ┐( ̄ヘ ̄)┌