In most cases, gender is determined by the chromosomes, and when we are born, doctors focus on the sexual organs to say "it's a boy" or "it's a girl". However, I don't think at that very moment the baby is born, they will know whether the girl really has a uterus or ovaries, they will "judge" based on whether she has a ****** and not a *****.
But in cases where people whose soul/ spirit is one gender are "trapped" in the body of the other gender, it isn't that simple anymore.
Are we able to deny them happiness by not making them switch gender? There is nothing we can do about their chromosomes, but should they be unhappy for the rest of their lives because of that?
Live and let live. If my neighbour, who is born a woman but feels like a man, is much happier being a man, who am I to deny him that? If he switches gender, does this affect ME? Nope.
There are way worse things in this world than people changing gender, being happy and having children.
A child is better off being wanted and having two loving/ caring parents, whether they are same gender, different gender or switched gender, than being unwanted/ abused/ whatever in a "normal" family.
For the record: Most "normal" families treat their children well, and my neighbour isn't transgender.