Companies which Donate

As Salamu alaikum,
A many Companies are Donating to the Us Military and also to the Lgbt Community etc.
Is it Haram from Islamic Perspective to buy the Shares of these Companies?