The part of the answer is that many women in STEM meet nice young men in STEM who make nice STEM pay checks. A lot of those women decide being a stay-at-home is more rewarding than living in a cubicle.
Also a lot of STEM women transition into management.
Also people working in STEM typically put in lots of hours. If you both work bin STEM you realize that it’s better for one to put in lots of hours and thrive than two at risk of being laid off.
My hubby and I met at work as software engineers.