Your description of identity does not accord with a mountain of research in Psychology about the emergence and formation of individual identity, including gender identity. “The self” is a thing that emerges through a dynamic, interactive relationship between the individual and social context. That includes gender identity. A great summary of this process of gender identity formation can be found in the first few chapters of Cordelia Fine’s magnificent book Delusions of Gender.
I actually (technically) agree with your latter two paragraphs but would say that the conflation of “sex” and “gender” is much older than the last generation. And, yes, because language is used to describe the material reality of the body, the naming of a newborn’s sex is the entry of their body into the regime of gender. But that language is accepted as making some kind of truthful statement about the newborn’s biological sex (which leads to all kinds of problems). Thus, terms like “assigned male at birth” describe the sorting of material bodies into gendered social categories with associated norms, roles, etc. etc. Not to get too philosophical, but the only access humans have to material reality — assuming such a thing exists — is through the evidence of our senses which we convert into representation: thoughts, words, and images. We have no unmediated access to the material reality of biological sex. So, in a sense, sex is only and always gender.
Lastly, it’s very important to remember that social context has effects on material bodies. “Sex” and “gender” may be different aspects of human experience, but that doesn’t mean they don’t affect, or even mutually determine, each other. The reason we can never be sure gender identity originates fully with biology or society is because we’re born without fully developed bodies, including our brains. Differential gendered treatment surely affects human development, including brain structure and function. This is most obvious with sex differences that result from different gendered behaviors involving diet, nutrition, and exercise. But could also affect less visible kinds of sex differences, like genetics, brain structure and function, and hormones. Thus, we can’t be certain whether some (not all!) of the physical evidence of sex differences is the cause or the effect of differential social treatment. Are the few differences in women’s and men’s brains, for example, the result of their different treatment in society? Or do fundamental physical sex differences justify and produce different social status and treatment of women and men? We could ask similar questions about the physical evidence and social status/treatment of sexual orientation or gender identity that researchers have identified in some human brains — is it a cause or an effect? Or both (as I tend to believe)? Bodies and brains do not develop in a vacuum…
But because “sex” and “gender” are intertwined and partly mutually constitutive aspects of human experience, we are likely to never fully know the answers to these questions.