As a candidate, Donald J. Trump disparaged the alliance. But as president, and facing a fresh conflict with Russia, he now embraces the organization as a pillar of security.