This shows an important point. There is a big difference between sex and gender . Sex is all about the body. Sex is how the body is shaped, how it functions, male or female. Gender is the 'sex' of the brain, apart from the body.
Gender is the identity of the person inside the body .
The two, clearly, can be in conflict. That is what a transsexual is, a person whose sex, whose body, is wrong for their gender, the person inside the body. Sometimes people use the two words as though they meant the same thing. They do not. Sex and gender mean different, but related things .