Dick Swaab of the Netherlands Institute for Neuroscience is a pioneer in the neuroscience underlying gender identity. In the mid-1990s, his group examined the postmortem brains of six transgender women and reported that the size of the central subdivision of the bed nucleus of the stria terminalis (BSTc or BNSTc), a sexually dimorphic area in the forebrain known to be important to sexual behavior, was closer to that of cisgender women than cisgender men.[1] A follow-up study of autopsied brains also found similarities in the number of a certain class of neurons in the BSTc between transgender women and their cisgender counterparts—and between a transgender man and cisgender men.[2] These differences did not appear to be attributable to the influence of endogenous sex hormone fluctuations or hormone treatment in adulthood. In another study published in 2008, Swaab and a coauthor examined the postmortem volume of the INAH3 subnucleus, an area of the hypothalamus previously linked to sexual orientation. The researchers found that this region was about twice as big in cisgender men as in women, whether trans- or cisgender.[3][1] J.-N. Zhou et al., “A sex difference in the human brain and its relation to transsexuality,” Nature, 378:68-70, 1995.
[2] F.P. Kruijver, “Male-to-female transsexuals have female neuron numbers in a limbic nucleus,” J Clin Endocrinol Metab, 85:2034-41, 2000.
[3] A. Garcia-Falgueras, D. Swaab, “A sex difference in the hypothalamic uncinate nucleus: relationship to gender identity,” Brain, 131:3132-46, 2008.
---
All of the above is from the first google result and about 30 seconds of searching. https://www.the-scientist.com/features/are-the-brains-of-tra...
So, yeah, science is beginning to try and understand this stuff.