Elon has a charitable foundation. This donation could have come from those funds. I'm assuming those funds would not be considered part of this wealth in regards to his cash-poor status.
One million dollars is ~1/23400 of his wealth. If you had $500,000 in your investment accounts, that would be like donating $21.
Neophyte here with a stupid question. What if he just used a credit card to donate money?