Rich people don't get rich by giving their money away randomly. For example, if Bill Gates didn't start the Gates Foundation his money would have been highly taxed, and he would have lost control of it. By starting the Gates Foundation he keeps control of that money, and he can use the foundation to steer policy in ways that are beneficial to him.
It’s only weird if you assume all corporations should be amoral money exchange systems where by money is exchanged for labor and capital which in turn is exchanged for more money
almost none of the people that make up a corporation are free to decide where money goes. the few people that do take the money out, the board of directors or whatever, could just donate their own money to whatever charity.
https://www.statista.com/statistics/487741/number-of-firms-i...
What you’re missing is the final step in the chain, which is the part where profits are distributed to shareholders. If I’m one of those shareholders, I might very well take a large chunk of those dividends and donate the money to charity. But instead of paying me more of those dividends to donate to my preferred cause, the company’s management has decided that they should be the ones donating my money to their preferred cause.
Aside from that, it’s just a failure of specialization. Philanthropy is hard, making money is hard, and building a single organization that does a good job at either of them is even harder. I’d rather have corporations that focused on doing a really good job at whatever they did and non-profits that do whatever they do as efficiently as possible, rather than a corporation trying to do both.