Researchers can do studies that track disparate impacts across genders just fine without the government storing your assigned sex as part of your legal identity. They do this with race and orientation and disability and so on just fine.
A census can understand population level trends just fine without storing your assigned sex as part of your legal identity. They can ask for this information in the census. The census tracking population level data is not the same as your assigned sex being permanently part of your legal identity. (At least, the way my country does a census.)
Your doctor can know your anatomy by you communicating it to them if/when it is relevant. There is never a time when they might need to know something that could only be conveyed by your assigned sex being officially relayed to them via government documentation. You can just use your words. The same way you tell your doctor any other part of your medical history.
People respond to "the government doesn't need to store your assigned sex as part of your legal identity" as if they are hearing "no one should ever acknowledge gender or sex at all" but that's not what's being said.
Your birth certificate conveys important legal information about you. Your name, as a designation. Your parents, as they have a legal obligation to you. Your place of birth, as that place has a legal obligation to you. Date and time of birth, since age is important for application of some laws.
And sex. That's on there too. But what is the legal relevance? What laws is the government going to apply to you differently based on what sex is on your birth certificate? I can only think of one thing my government really uses that for, and that is to determine who has to sign up for the draft. And guess what, fuck that shit anyway. The government also used to use this to decide who is allowed to marry who. They don't do that anymore. For now.
There is literally no reason my assigned sex needs to be part of my legal identity. My government is not using that for anything (important). It doesn't matter. If the gender markers on everyone's IDs vanished tomorrow nothing (except maybe the draft) would be significantly negatively affected. Data collection for research could continue as usual since researchers usually have people self report these characteristics rather than checking their government IDs. My doctors would still know which organs I have and if they forgot, I could tell them. I don't want anything to be part of my legal identity that doesn't have to be.