People in general set a lot of their internal norms based on what is socially acceptable. Many (most) people have times or things where they would like to do stuff that are widely considered Not On. Maybe not super serious things, but stuff like not bothering cleaning out trash bins, or eating the food other people leave in the work fridge. And also more serious things, like not peeping on people in the toilet.
There is a range where people will try and get away with these things but secretively, or in some cases may do them but feel guilty knowing it's wrong, but they do actually work for a lot of people. Both at an individual level and maintaining social norms that help keep things on an even keel.
I suspect there will always be a capacity for people, especially men, to develop odd fetish interests. I remember reading about the rubber guy and how he was first aroused by rubber seeing a wet suit as a kid. Well - that is not anyone's fault and not much could be done to prevent it. But in a society where that was seen as not healthy, a person might make an effort to avoid letting negative sexual interests become obsessions. Many boys who might be interested in dressing as women might just not actually do it so it doesn't become a reinforced behaviour. We'd also be limiting exposure generally to certain types of material.
Obviously this will not prevent everything like this, but those boundaries do make a difference. But right now our society does not actually seem to recognize the value in things like boundaries, habits, etc, in sexual things but also in self-regulation more generally. The assumption is we are born a certain way and these capacities "develop" and it's wrong/ineffectual to try and limit that.