I think that they're doing it because of the marketing gain. IBM wins a contract easier when the client sees that they're developing the IDE too. And IBM has to invest just a little bit into Eclipse, because there are other "fools" that do the rest of the work for free/just for reputation.
Similarly it's a good marketing campaign for hardware manufacturers to invest a little bit in Linux development. System administrators, who recommend what equipment to buy, are "bought" by this marketing.
Or for Google to invest a little bit in Android. Tough they now do most of the work, probably they hope that later 95% of it will be overtaken by volunteers, and they'll remain with the marketing benefits.
The story is the same with the donations/charities. You, as a company, buy the members of the foundation to who you give charity. So, as individuals, they'll buy from you, instead of from the competition. And they'll recommend you. And you also buy the ones who just find out about your donation and like the cause you donated for.