If you are a billionaire and give money away in private, you'll be publicly criticized for not giving anything to charities. You're guilty unless proven innocent, so to speak.
Or take somebody like Warren Buffet. For years people had criticized him for ignoring charities, while he was of the opinion that he could put the money to better use by investing it wisely. A few years back he decided to join forces with Gates and signed almost all of his money away to charity. And suddenly, of course, the media flips and applauds his generosity.
The strategy of keeping all the money during your career and giving it away in a lump sum in the end may be a close to optimal solution (because you give away everything you're going to think very carefully about how to make the biggest impact. Otherwise you'll pick a few charities at the end of every year for PR reasons and for tax benefits; that's not going to be optimal.)
To criticize a billionaire when he wastes obscene amounts of money (yachts/private planes) I can understand (although I think they earned those luxuries). To criticize people for investing the money they've made, when there's no reason to assume they're not going to give the same money to charity in the future, well, that's just petty.
Keep in mind he also has some investments in biotech too. Giving someone money in order to allow him to buy your products and prop up your market cap may be a very profitable form of charity ;-)
My grandmother loved to donate as anon0 to people, sending large lump sums to people in need, directly in the form of cash in their mailbox or otherwise delivered as a "gift" with no "from". I hold humble charity in the highest regard, and whenever I donate, I refuse to put my name to it to this day, as a gift given for recognition feels cheapened.
we didn't find out until after her death, my mother was normally her assistant in sending and getting it to the right places and she didn't disclose any of this until after her passing, in memory of her and to honor her.
Other than that in general, I've observed many occasions where if given the choice between giving or not, the major factor in their decision was whether or not other people would know about it.