Afraid that the objections of House members who did not want taxpayers paying for sex reassignment surgery would derail the bill, House leaders came to Trump and told him that the appropriations bill, which in addition to the wall funding also provided money meant to implement other promises from the president, was in trouble.

They wound up getting a little more help than they bargained for. Rather than a limited restriction on specific medical procedures being performed with government dollars, what they got was a series of presidential tweets that, taken together, articulated a complete ban on transgender people serving in the military at all.

https://www.thefiscaltimes.com/2017/07/26/Trump-s-Trans-Ban-Was-About-Costs-Just-Not-Ones-He-Claimed