Someone in a Hacker News thread said something that gave me a revelation:
Selfishness and shortsightedness are one and the same thing.
When you choose immediate gratification over later reward, you are being selfish; not toward another person, but toward your future self. You treat your future self as a different person, and if you don't feel compassion toward that person, you won't be inclined to help them.