Hormones of course differ in the womb according to the child's sex, as that's how development (usually) goes from chromosomal cues to physical outcome. And subtleties of brain formation would be as likely to be subject to the basic mix as whatever form/placement your gonads took and the rest.
And it may be that there are secondary effects from trans-placental chemicals, too. The old 'second boy is more likely to be gay' chestnut[1] being that of those hormones that do cross the boundary, some might have been in the mother's system due to the prior pregnancy.
Not so simple as permanently hanging around, and the placenta does do a lot to inhibit much transfer across the barrier that isn't vital for foetal survival, but some trace of transferable 'signal' left over by the general wash of chemistry might wash back again in the next instance. Any advantage (e.g. the "aunt and uncle effect", where there are handy co-parenting individuals who are able to help bring up the generation after them) could find itself evolved into the natural variation of the brain through subtle cues such as this, perhaps an epigenetic element that gets squirreled away, chance triggering a different valid path of brain (and thus mind) development that
on balance is positively advantageous to the lineage that holds that potential to hold all such roles.
I wouldn't rule out nurture effects also. For tipping the post-natal potentiality one way or other from a tottering position as set up by genetics and the rest. As long as such differences have been historically an advantage to the holders (if not users) of the inbuilt likelihood, once the possibility exists then it
will happen.
Not that evolution has had time to work with such influences as social media or totalitarianism, which could perhaps exagerate or prosecute such tendencies. Such things as global social evolution and possible medical interventions being something we haven't had for much of human (and precursor) history, as well as the will and opinion of heads of tribes being far less impersonal (within their own little huddle of people) than it became once there started to be kings, emperors, leaders of superpowers or indeed other political/social influencers with alternate jurisdictions to exert their power across. What may have integrated seemlessly into intrinsic human behaviour in ages past (unnoticed, because it always seemed perfectly normal to have whatever mix of personalities and social reactions one grew up amongst and lived in) now
looks weird (or interesting, or terrible) as you get to notice the clumping together of meta-tribal behaviours into groups that either reinforce or seemingly destroy the place one perhaps thinks one inhabits in the world.
So is gender (in any sense) a social construct? No, I think it's probably no more that than anything else not
entirely phenotypical (the purely physical sense of gender is phenotype, mostly arising from genotype; in its bare and entirely unclothed sense, in the absence of socially-inspired surgery). But I think society may amplify and even catalyse the expression and diversity of it (when not suppressed or forced into narrower expectations[2]), in a highly visible manner. Whilst the underlying cause of all this variation is down to some massively chaotic mix of long- and short-chained molecules interacting in a staggeringly huge variety of ways that
tends to produce a person who is an individual l. Who is going to be unique amongst other all the other unique individuals, however you try to conveniently pigeonhole everyone (or force pegs of one shape into holes of any other).
[1] This turned out true for a friend of mine. Though as his first child was by a different mother, I can't see it counting as evidence towards the cross-placental assumption.
[2] Not just towards binary, but "you're gay if you're not not straight" anti-Bi prejudice within "LG" circles, or Trans-excluding, etc.
edited for typo and minor clarification