I think it works both ways. An action can bring another pleasure through unintended consequences, and that makes us feel good too.
Then there's sympathy. Listening to a stranger pour their heart out can be tedious, but we may do so because we recognise their need. That can be put down to the ego, or self-love, but we're not sitting there thinking "I want to be a compassionate person" throughout.
When someone dives into a river to save another's kid, they're probably not thinking very much at all. I haven't done any research into it, but I would suspect the instinct is in most of us, but some people act in emergency and others freeze.
I don't think it's transactional, "what we can get in return", but I do believe that no one's self interest is ever really at an individual level, and can never be distinct, or contrary to, what is best for society (depending, I guess, on how you define that).
Still, I grant that you can frame it so every act is selfish. It's not obvious from the quotes you provided that Hume disagrees with that, but I can't claim to know what he thought, and I haven't read that work.