I doubt he cares one way or the other about trans people. He cares about winning.
He's doing it because he said he would, and he said he would because it meant he could score easy points against the Democrats and because it's what his support base want and they will laud and celebrate him for it.
The man you see saying these things and caring about them is not Trump himself, it's the persona he created to appeal to the voters who started to support him and has evolved over time in response to their priorities and the message they want to hear. He is just doing this because it is what his character would do. And that's more terrifying than if he actually cared and believed this stuff because there is no limit, no moral framework that can come from inside, he will just keep on fulfilling the demand.
I'm not entirely sure there even is a real Trump in there as a fully formed personality, just a screaming aching black hole of pain and shame driving him to cling to anyone who shows him approval and to attack pitilessly anyone who shows him less than total respect.