Musk laughed and agreed as Trump described a nation on the verge of the apocalypse—even where it put him at odds with the tycoon’s own business interests.