Sex and gender are different but related things. Neither is binary. For an accessible introduction to why sex isn’t binary, Wikipedia is not a bad place to start.