The Canadian prime minister framed the spending as a necessary response to a world where the country is more vulnerable to threats — and less protected by Americans.