I think it’s social, and not just work environment. Working a job outside of what’s typical of your gender is still socially considered weird. For example, going from the other side, being a male nurse is going to get a reaction out of friends, and family. There will be jokes. I’m sure a female programmer is going to have the same social barrier outside a work context.
There’s also the fact that most people don’t want to be the only X person in the group. The single women, the only black guy, the alone, etc. As welcoming as you try to make the work environment, it’s also just going to take a bit of a critical mass. I think I read somewhere that’s the most common reason that women leave. Which is a bit of a catch 22, women join and then leave, never building up the numbers to solve the problem.
edit: Not to downplay general sexism that still exists of course. I’m sure there are still discriminatory hiring practices contributing a lot. I’m just talking about situations where there is significant female interest, industry drive for inclusion, but still a gender difference. I don’t think anyone’s pushing women to be auto mechanics (I imagine would be pretty toxic for women, if they can get in the door), or men to be child care workers (I imagine most places won’t hire men).