Generally, there are three positions a corporation can take on social responsibility. The first is to decide to not engage in any. The second is to decide to engage in social responsibility as a means of marketing. And the third is to engage in social responsible activities because of a feeling of obligation to the community.
In the first instance, a corporation may decide that social responsibility should not be part of its responsibilities for two reasons. One is that its primary obligation is to its shareholders, to maximize profit. To the degree that social responsibility activities take away from this, a corporation can feel that it is not performing its primary obligation. The other reason for a refusal or failure to engage in social responsibility is that this is not the corporation's area of expertise, and it is best left to those whose area of expertise it is.
A corporation can justify social responsibility spending on the basis that it is good for the bottom line. When companies engage in these activities, it is a form of marketing. Sponsoring a sports team gets the company name on the jackets, for example. Making a large donation to a cause and announcing it at a press conference gains the company attention and praise. Supporting a particular cause that many people support, for example, the treatment and cure of breast cancer, can gain the company new customers who also support the cause.
Finally, there are no doubt companies that feel an ethical and/or practical obligation to give to their communities. They do this because they feel they should do this, as "citizens" of their communities. They also might understand that they cannot exist without the community, so it makes a great deal of sense to support it. One example is helping a community to overcome blight. If blight spreads, this will inevitably hurt the business, so from a practical standpoint, the company can do good for others and itself.