The bulk of his wealth is the Tesla stock. I know that SpaceX produces value. Some of his ventures do. But the image of a genius entrepreneur is way more valuable than any government contract he might get.
Remember he was way less crazy before his market cap skyrocketed. Now he can afford being polarizing as a PR strategy once his fanbase has reached a certain critical mass. He’s been constantly testing what works.
He would be one of the richest people in the world even if he didn't start both SpaceX and Tesla, just from what he made from the sale of Paypal. Hell, he'll be one of the richest people in the world even if he didn't start the original X and just lived off the $13m he made from Zip2. $13m still places you in the top 0.5% in the world today.