In foreign policy, Mr. Trump mixed praise of the NATO alliance with bursts of isolationist and xenophobic rhetoric, claiming the United States had “defended the borders of other nations” but not its own.