Musk cosied up with Trump because he saw a way boost revenue with lucrative government contracts and a prez that is buyable wrt whatever other projects he has planned (Orion/Starship, Robotaxi etc)
He had a falling out with Trump when he realized that the winds were blowing in the opposite direction than anticipated.
Their only ideology is money, nothing else.