That definition of "gender" is ad hoc, and was not used until very recently. "Gender" has always been used interchangeably with "sex" as in the "male sex" and the "female sex." Originally, it applied to languages like Spanish and German that gender their nouns.
People said "gender" instead of "sex" because children and childish adults would giggle if they said "sex."
The argument that a person can be a biological male, but claim female as their gender is made specifically for the purpose of forcing people to accept males into female spaces, and very rarely, vice-versa. As so often, the left manipulates the language in order to slow down debate.
It works, because here I am talking about "gender" vs. "sex," instead of how obviously wrong it is to subject young girls to males in their locker rooms, bathrooms, and playing fields. It's wrong for people of the male sex, and just as wrong for people of the masculine gender. Gender and sex are one and the same. You cannot be male sex and feminine gender, that is not possible in reality.
The idea that a person is male sex, but sees himself as a girl or woman is about delusions, not about definitions.