All models are approximations of reality, thus they are ideas humans make in the context of their social situation. Norms and attitudes impact what we research, how we interpret data, and what we end up believing.
While the aim of science is to get closer to the truth the end result is going to approach but never reach perfect accuracy. With gender we see the social norms all through the expression of gender in different ages, generations, socioeconomic statuses, cultures, and countries. With sex we see a flattening of what is present into a strict binary with exceptions rather than what is actually present, a range of different karyotypes, sensitivities to hormones, levels of hormone production, interactions in regulatory genes, and differing morphologies. Gender is a diverse spectrum, but so is sex, and the reason we teach the XX XY version is the same as how we teach mathematic ideas. Basic stuff first, then expanding on that idea, then going further until we have the capacity to really understand the basics, like the multiple page proof that 1+1=2. Yes, basic biology says male and female, but intermediate talks about the diverse presentations of sex.