I'm really not trying to ignorant here and please, if I say something wrong or hurtful I want to be educated.
The way that I always saw it is that Sex, may be determined by genes, but Gender is a social construct that only exists because of years of pushing specific gender narratives. So the government saying "Sex is determined by genes" is missing the point entirely, since your gender wouldn't be determined by any sort of genetic makeup.
Again I'm not saying this to bait anything, this is just how I've had it explained to me in the past. I am 110% on the side of Trans Rights.
So, when people are talking about Gender they're typically talking about one of three things. Gender Roles, Gender Expression, and Gender Identity.
Gender roles are the roles assigned to men and women throughout the state or country, or even more personal areas impose upon them. A man has to be the provider, a woman has to be the stay at home mom is a pretty common one from the 50's that people remember that we have moved on from as an expectation. Gender roles are informed by the society that we live in, so it's fair to say that these are a social construct.
Gender expression would be how you express your gender identity. Someone who identifies as a woman may go for feminine hairstyles, feminine clothes, mannerisms, and so on. As you might realize, hairstyles, clothes, and mannerisms differ throughout different cultures and are largely informed by societal pressures that surround us such as influences from media, parents, school, and so on from an early age and onwards. It would also be fair to say that Gender expression is a social construct.
Gender identity is the core sense of self that you have that determines the gender that you identify as whether that's a man, woman, or nonbinary. You might be under the impression that trans people look at the above categories of gender role and expression, see where they fit best, and identify that way, but that is incorrect. We actually have quite a few studies that point to there being a biological component to being trans like these :
"A twin study published in the International Journal of Transgenderism found that 33% of identical twin pairs were both trans, compared to only 2.6% of non-identical twins who were raised in the same family at the same time, but were not genetically identical."
(Source:
http://www.hawaii.edu/PCSS/biblio/articles/2010to2014/2013-transsexuality.html)
"Several studies have found a correlation between gender identity and brain structure.
[7] A first-of-its-kind study by Zhou et al. (1995) found that in a region of the brain called the bed nucleus of the stria terminalis (BSTc), a region which is known for sex and anxiety responses (and which is affected by prenatal androgens),
[8] male-to-female trans women had a female-normal BSTc size (like cisgender women) and female-to-male trans men had a male-normal size. While the transsexuals studied had taken hormones, this was accounted for by including non-transsexual male and female controls who, for a variety of medical reasons, had experienced hormone reversal. The controls still had sizes typical for their gender. No relationship to sexual orientation was found"
(Source:
https://en.wikipedia.org/wiki/Causes_of_transsexuality#Brain_structure)
"David Peter Reimer was a Canadian man born physically male but reassigned as a girl and raised female following medical advice and intervention after his penis was accidentally destroyed during a botched circumcision in infancy.
Psychologist John Money oversaw the case and reported the reassignment as successful and as evidence that gender identity is primarily learned. Academic sexologist Milton Diamond later reported that Reimer's realization he was not a girl crystallized between the ages of 9 and 11, and he transitioned to living as a male at age 15. Well known in medical circles for years anonymously as the "John/Joan" case, Reimer later went public with his story to help discourage similar medical practices. He later committed suicide after suffering years of severe depression, financial instability, and a troubled marriage"
(Source:
https://en.wikipedia.org/wiki/David_Reimer)
We do not know exactly what causes someone to be trans, and it is likely a mixture of both biological and societal components. However, the above studies and the general ages that people discover that they're trans in all cultures across the world lead us to believe that there is a biological reason for trans people to exist and that it is perfectly natural.
Sex and Gender do differentiate from each other. Sex is typically considered by a lot of people to be Male or Female determined by chromosomes XX and XY. However, there are quite a few people out there who are born Intersex or with chromosomes that differentiate from the norm of XX and XY. One example of this is XXY or Kinfelter Syndrome which occurs in 1 or 2 per 1000 live male births. You can read more about that Syndrome in particular here :
https://en.wikipedia.org/wiki/Klinefelter_syndrome
On top of all of this, the basis for considering sexual orientation and gender identity under sex discrimination is largely due to the lack of any clear laws preventing discrimination against LGBTQ+ people in most of the country. The general logic that goes behind it is, if someone is considered male by society, they are expected to show up to work in dress clothes considered appropriate for a male, act a certain way, talk about girlfriends, and other generally straight guy things that most people don't even think about. The ways that LGBTQ+ people differentiate from cis straight men in the workplace causes us to stand out in various ways, and when people discriminate against us on those grounds, they are discriminating against someone because they do not meet the expectations of their sex, aka sex discrimination.