Mr. Musk has had a complicated relationship with AI, saying in one breath that it could bring humanity into a golden era and another that it could destroy human civilization.