You don't really "save yourself from taxes" by donating money to charity.
Option A: sell stock for $100, pay taxes of $20, spend $80 on yourself Option B: donate stock of $100 to charity, and spend $0 on yourself
Which of these options leaves Gates with more money in his pocket to spend on himself?
Giving money away doesn't save you from taxes on your income; you just forego the income entirely. The money is gone. It's no longer yours. Why would you be paying taxes on it?