The race has become a proxy war over Trump’s agenda and has attracted record spending by Elon Musk and others.