While gender can refer to the condition of being male, female, or transgender, it can also refer to your sexual identity. Like this gent (or lady) in the comment said there are many more genders than there are are sexes. Sexual identity in short is who you are attracted to. I am of the personal belief that attraction is on a spectrum ranging from no attraction to very strong attraction. An individual can have varying degrees of attraction to the different sexes. For instance I know two people who are bisexual but one of them is more attracted to men than the other. There also exist people who have little attraction nether to males nor females; likewise there are bisexuals with a strong attraction to both sexes and have no preference, and there are even those attracted to transgender people.
I view this phenomenon as a natural form of diversity in our species. From the standpoint of evolution, the species that is the most diverse has the most chances of survival. The human race is no different, this is a diversity that exists in the mind, much like there are introverted people, extroverted people, and those who fall into a middle ground.
I hope this let you extend your thought process on the matter! I had fun thinking about it