Many words have more than one meaning. For example, putting money in the bank probably doesn't require a trip to the side of a river. That's usually not a problem. Sometimes, though, arguments and ideologies (or metaphysical speculations) may equivocate (i.e. they may draw conclusions illicitly by mixing different meanings).
That's exactly what has happened with trans ideology regarding 'sex' and 'gender'. There's a simple way of escaping from fallacies of equivocation, however: disambiguate.
Here's an example.
If 'gender' means the same as 'sex', there can be no sense to talk of a person's gender mismatching their sex, as that would be the person's sex mismatching their sex, which is absurd.
If 'gender' means something other than 'sex', and we want to consider whether someone's gender matches their sex, we will need an explanation of how something other than sex might match or not with sex. (Usually only things of the same general sort can be held to match with one another, after all.) In the absence of such explanation, we conclude, again, there is no sense to talk of a person's gender mismatching their sex.
Overall, then, we conclude, whether 'gender' means the same as 'sex' or not, talk of someone's gender failing to match their sex is plain nonsense.
Of course matters may look different if we equivocate, as Stonewall & co. have shown time and again.
tldr: Don't fall for fallacies of equivocation: disambiguate.