As Elon Musk has led an effort to slash government spending, his own companies have, over the last few years, received billions of dollars in government contracts.