Gender and sex are not synonymous.
Gender refers to the social and cultural aspects of maleness/femaleness.
Sex refers to the biological aspects of maleness/femaleness.
Yes, "stereotypes", norms and expectations play a role in gender. You state that there is individual variation how people express their gender, which is true and it is why gender is often considered to be more of a spectrum than a strict binary.
I really don't understand the fervor with which people insist that these two concepts are the same... They are just words. Everybody should agree that these two facets of maleness/femaleness exist (as it is self-evident). Gender and sex are the words that have been chosen to speak about them.
PS: Why are there so many "transgender" related thread lately?