Okay, so I think we're just differing in opinion about the DoD vs. DHS. I look at "defending" the border as a function of the Department of Defense. As in a physical, defensive barrier to entry. Homeland Security, while certainly related has (to me) a little more nuanced meaning including intel, screening, asylum issues, etc..
It's more than just that. You're also thinking it was a simple executive order. Trump invoked the Emergency Powers Act. My position is that 1) to use emergency power to direct funds to some remedy for that emergent crisis, the thing he diverts funds to should be an emergency action, not a long term action. 2) This was an abuse of power because he used a mechanism not intended for the purpose of getting around a congress that wouldn't give him what he wanted. 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.