By identifying different brain structure and function in the two groups.
That is what the research is about, here is a meta study on gay vs trans brains;
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8604863/
This basically says (to me) that the jury is out - some studies find differences, some...