There is no question that the president has the full discretion to declare a national emergency. And there are more than 130 statutory provisions at the president's command under a declared emergency. And he's free to utilize any or all of them while under an emergency, even if they are completely unrelated to the emergency. The president could declare a national emergency in case of a hurricane, and then sieze complete control of the internet, for example. He could declare an emergency because of a drought, and the seize control of the internet, or freeze and even sieze private vehicles at sea, or sieze private bank accounts.
Every time a president has acted upon these statutory powers they have been challenged in court, and only once successfully, when Truman tried to nationalize steel mills during the Korean War. Every other time the lower courts and/or the Supreme Court deferred to the president.
SCOTUS has already ruled that the president has many inherent powers as the commander in chief that can go well beyond the military, especially when related to national security. The premise of the national emergency declaration, and the powers given the president, is the government’s ordinary powers might be insufficient in a crisis, and amending the law to provide greater ones might be too slow and cumbersome. Emergency powers are meant to give the government a temporary boost until the emergency passes or there is time to change the law through normal legislative processes.
If the president declares a national emergency, historical precedent says the SCOTUS will defer to the president, and tell Congress to go through the normal legislative process to limit presidential power of they don't like what he's doing. The places where Trump is talking about taking money from is not from already-allocated money designated for specific projects or purposes, but rather from money that is been set aside waiting for someone in the administration to decide whether or not to spend it. It's unlikely that SCOTUS will intervene.
Thus far Trump has been reluctant to use national emergency powers for the wall, despite the current state of the porous border security betting a national security emergency. He knows that every president has pushed the limits of their power, and every subsequent president has taken that same power and pushed it further. Trump can well imagine, say, a President Alexandria Ocasio-Cortez declaring an income inequality national emergency and redistributing wealth any way she sees fit.