Eh, evolution doesn't really care about our survival. It's all about passing on the genes. And not necessarily the genes in our bodies. Kin selection is one of the more prominent evolutionary explanations for homosexuality. The thinking goes that our siblings carry most of our genes, and in some cases selection pressures favor behaviors that allow the gene copy in the sibling to survive, even at the expense of the genes in the host body. Homosexuality could have evolved as a resource diversion mechanism in kin selection processes, the gay person is not worried about passing on their genes, so their resources can be partially diverted into helping the sibling survive. A similar explanation could exist for the craving of opposite sex hormones. Us being trans could help other versions of the trans gene (or genes) survive in our siblings.
Or, alternatively, transness could be a evolutionary misfire. Dawkins attributes altruism in a modern society to a misfiring of the instinct towards reciprocal altruism. We survive in the wild based on our status with in groups, and we can lower that by failing to pay kindnesses or return on past kindnesses. In the modern world, that group memory for our status is rarely present, but our minds are still firing on those old triggers, we are kind due to that misfiring. Maybe, in the modern world, being trans doesn't do much for our genes, but in our evolutionary past, the behaviors associated with being trans lead to some increased survival chance. We just live in a world where we can take those behaviors to their full and complete fruition, even if it nixes our ability to pass on our genes. Which, by the by, isn't necessarily a bad thing, overpopulation being what it is.
Or it could be a mutation in our genetic code, or an event in the womb environment, or an epigenetic trigger. In any case, the mind is the play thing of the body (which includes the brain) and we would be this way even without the social context provided by existing gender structures.
Also, I agree we act, and then reason, but would the body create pleasure when ingesting the hormones of our gender, without a society?
I don't see any reason why they wouldn't. I reason we would also eat, sleep, and masturbate. Without the social net of other beings of our species, we wouldn't pass on our genes by doing so, but all the same programming would be there.