We can only really go off what he has said and he said he always voted Democratic until recently.
No one said he was a "lefty liberal in college".
He certainly was far more environmentally minded, which fit with what Tesla were trying to achieve with their cars and solar projects. He said in 2018 that "“climate change is the biggest threat that humanity faces this century"....
https://www.rollingstone.com/cultur...n-is-an-antidote-to-climate-pessimism-196804/
He even encouraged a carbon tax...
https://www.cnbc.com/2021/02/12/elon-musk-reducing-greenhouse-gas-emissions-with-a-carbon-tax.html
Now, he is all in with the party that denies climate change and is pro fossil fuels.
As i mentioned before, one of the things that seemed to turn him away from Democrats was being snubbed from Bidens EV summit.
He was also fighting with the California government during COVID as they shut down non essential businesses - his Tesla plant was considered non essential.
People like Musk are not used to being told what to do. He then seemed to go down the right wing rabbit hole of vaccine scepticism and became this "free speech" warrior, which he started getting more and more attention for. We know that the more controversial things you say, the more attention you get. The attention becomes so addictive to him that he buys twitter.
Two years later he is donating to Trump in a huge way with a view to be working within his government. We can only imagine the financial benefits that would bring to him.
Democrats wouldn't let that happen. Can you imagine a Democrat President allowing Musk to run a "Department of Government Efficiency" ? Musk sees an empty vessel in Trump and wishes to exploit it.