I see it naively like this: life is a long process of eliminating options that don't meet your interests or best chances at success. Women in general have more options in life than men, career being only one aspect of that, which means that over time, any one of those options is going to be chosen less and less.
Sociology distinguishes itself from economics in the assumption that people's choices are the result of stupidity or victimization. I just looked up the top math student in my 5th grade class. She's a 5th grade public school teacher after attending an Ivy for Geography. I have not the slightest clue why one would ever study Geography in college, nor would I find it financially prudent in my situation to be a public elementary schoolteacher, but I also know this person to be quite smart and fully-capable of making her own choices. I talk to female H1B engineers that came here for a better life, which was not STEM work, so they often quit as soon as they get a green card. I see women retiring earlier to start new careers. Female attrition is a constant feature of the entire STEM pipeline.
If I try to be honest with myself, I will admit that I was not at all intellectually interested in my engineering degree. Computers were always about creation and expression and social possibilities to me, not the pedantism and rigor that I practiced for financial reasons. I think we all just saw it as a test to see whether we could make it, or how well we could do, a game. It might as well have been pinball, and it never ends. 30-year SWE veterans still play leetcode. I am constantly being told that the opportunity to unleash my creativity and wonder upon the world is just around the corner. I should have dispensed with all that and started out as an artist.
All the STEM greats quit this game early. That says something. If Gates, Zuck, Musk, Jobs, etc. had never taken DiffEq, would they have been any less capable or motivated? I doubt it. The women that abandon STEM may have more in common with them than we admit. They're probably doing something better with their lives.
Maybe women leave STEM because they can.