I don't know whether transgenderism is a mental affliction or a physical one,  but either way, it is a condition that will require years of medical treatment to "cure".  We don't allow people with club feet or rickets to join the Infantry, since neither can walk the walk without large amounts of medical intervention.  We don't allow allow diabetics to join,  nor those with other diseases or conditions, because of the increased medical care needs that detract from their ability to perform active service.  It seems reasonable to prohibit known transgenders from enlisting to prevent the long term and expensive medical care they would need in order to perform their duties.