Mr. Obama pleaded with Americans during his remarks not to “give in to fear or turn against each other,” a somewhat muted reference to Mr. Trump’s previous call for a ban on Muslims entering the United States.