The enormous spending from the world’s richest man quietly fueled allied groups and was revealed only now, as Mr. Musk plays a key role in the presidential transition.