Buying something produces a direct, instant, and tangible return. Donating most often only produces delayed returns that are indirect and/or intangible.
People may feel better about themselves when donating rather than buying - donating can contribute to self-esteem by producing feelings of altruism, compassion, and empathy. Because you get something in return for your purchase, buying may not produce similar emotions.
It's an evolutionary advantage to provide for oneself before providing for another. However, in today's society there is such an abundance of stuff (new car, iphone, levi jeans) that there is no limit to what we can give ourselves, so we continue, even while others go without food and clean water.