If he had the power to simply divert the funds all along, he would not have needed to seek the funding from congress, and he would not have had to invoke emergency powers. He could have just written an executive order.
I think it is pretty simple that the funds earmarked for the military construction were considered a good use of funds.
You don't start by diverting funds from something you want anyhow. You start by wanting that funding to go ahead and build the military construction and you ask for more money for the next project. That is why he asked congress for the money.
When that didn't work then you go to plan B.
Your objection to his starting by asking congress is irrelevant to whether or not plan B is legit.