Or because they aren't the only one leaving it in the first place!
Thinking that any man or boy is the same, act the same, think the same and like the same things, and STEM faculties are the worst a woman can find, is naive at best.
Men suffer as women.
The survival bias make people think that only women leave STEM or leave it at bigger rates, but that's not true.
Statistic says that less than 5% of boys and less than 1% of girls think of a career in STEM, it is already largely a field for a few (an élite if you like) and it's dominated by two kinds of people: people obsessed by the topic, in the autistic spectrum, that is mostly a male disease (people in the spectrum gravitate around STEM majors 14% more than neurotypical people - 22% Vs 36% - it means almost 2 times more).
Competitive assholes who like other competitive assholes, who are mostly men.
But the bulk of the students are regular folks like me, who just wanted to study the field but didn't like the academia shit and hence left (and I am in the spectrum as well).