Ah, Grumm - you perhaps don't see the deeper issue.
People are adaptable to the point that they can live a lie. Take a look at deep-cover spies and long-term fugitives. Take a look at illegal aliens. They all adapt to a situation that hides their reality. Take a look at "wage slaves" who go to a constantly frustrating job because it is what they have to do to keep the wolf away from the door, even though they would MUCH prefer some other line of work. These people open themselves to a life of permanent paranoia, waiting for that tap on the shoulder that is reality, come at last to take you in and expose your secrets, to end that life of unstable equilibrium. We need not consider the parallels for those who rigorously proclaim the coming of judgment from religious points of view, but the paranoia is similar.
Consider the case for my gay stepdaughter. She tried to live within ideals imposed by her father (my wife's 1st husband) by dating guys, but she discovered they did nothing for her emotionally. She eventually recognized her preferences didn't follow socially normative behavior. She liked girls. Her biological grandfather pretty much disowned her when she came out and cut her out of any inheritance. Her father did almost the same except he is still alive and spending his money on his 3rd wife's kid. My stepdaughter was ostracized within the father's side of the family because of the intransigence of country Catholicism. My wife and I, on the other hand, look at character first. So for us, the fact that she got a good job, a good education, and served her country in the USAF, and now has a stable home and relationship are all FAR more important than the plumbing on her partner. And her partner is an honest and caring woman, which helps.
One of my good friends from a long-running D&D campaign was gay. He told me that he was about 16 or 17 when he realized he was gay. Before that, it had never been an issue. I would say that it never came up, but that isn't true. It came up at awkward moments but he was able to handle it.
One of my best friends from college, who was also my partner in the tournament-level game Duplicate Bridge, came out to me one day when we were coming back from an afternoon bridge session. She was nearly in tears because everyone - including her own sister - was asking her when she and I would get married. The constant questions had stressed her out. I hadn't asked her about marriage at all and probably wouldn't have done so anyway for reasons unrelated to her gender preferences. When she finished her story, she said we couldn't get married. I asked if we could still be friends and another round of tears started to flow. But during her self-outing session, she admitted that she had realized the truth about herself as a younger person in junior high, perhaps 7th or 8th grade. Her own older sister did not know at the time that E finally came out to me, even though they had lived together for over 20 years by then.
Therefore, Grumm, I must correct you on a fine point. It is not that these people change their gender when it is convenient. The change is that they choose to make public that which they have known for some time, something they have been hiding because of social pressure to conform to rigid ways of thinking that were making them live a lie. The change was the advent of honesty. What was that Shakespeare quote? "This above all: to thine own self be true, And it must follow, as the night the day, Thou canst not then be false to any man."
I have to admit I don't understand the "robot" comment but will leave it to you to either explain or not as you see fit.