Male and female are biological sexes. Most people are male or female, but there is also intersex people and people who don’t get an assigned birth sex.
We in the LGBTQ see sex and gender as two different things. Sex is the biological. Gender is something that can be chosen and changed if needed. There are many different genders because humans are a complex species that experiences things in quite so many different ways. It is useful to have labels to explain these unique experiences and as a way to share these ideas with others. It helps with understanding.
Male and female are not genders, they're sexes. There are many many more genders, but also more than two sexes as well. Intersex people have been erased for a long time, and I've been doing a lot of research on them lately.
You are correct. Sex is determined by chromosomes. Doctors typically use physical traits to assume what chromosomes someone has to assign sexes. Chromosomes can not be changed currently, but that is ok. It is not the chromosomes that cause dysphoria/uncomfortability.
Male and female being used as genders is a leftover by-product of a time when gender and sex were used interchangeably to mean the same thing. It's more accurate to say your gender is man/boy or woman/girl depending on one’s age.