I think it's simpler than that. He always wanted to keep the kids in DHS custody with their parents, while the parents were (almost surely) deported. But the "Flores" decision said the kids cannot be held. They were being transferred to HHS, separated from parents still in DHS deportation proceedings.
There was an outcry about how terrible this was. Trump let it run a week or two.
Then he solved the problem, but not in the way the Dems wanted. (They should have expected it though. These people are stupid!) Now he's perhaps violating the Flores decision, and if you read the EO it asks for courts to revisit it, or Congress to write new legislation to create a workable system.
Meanwhile he's going to build more shelters to house the families, with the kids, so they can all stay until their hearings and denials, and they can all be deported together! And he's' going to use DOD money to build the shelters!
Winning.