Sex is your genitals and pelvis shape, along with your chromosomes. Gender is the way that you want to be viewed. While having the trans surgery doesn't change your sex, it does change your gender.
And there are more than two genders.
Just a few other than male and female: genderfluid (like me), non-binary, agender, bigender, Pangender, demigender, and hundreds more