Gender is the cultural articulation of sex.
Sex can be articulated in a number of ways, depending on the economic and emotional needs of a culture.
But culture isn't always good at finding an articulation that meets those needs, and different aspects of culture can change in different ways, especially if the economic and emotional landscape is unstable, and the articulation can become inconsistent or self-contradictory.
That sort of disconnect isn't unique to modernity, but seems to be characteristic of it.