The problem is the definition of "first," and keeping it from becoming "only." Phrasing it at an either/or (as often happens even inadvertently) is the problem.
You need to achieve a certain level of self-stability/health before you're even useful to others, and before doing for others wouldn't end up causing harm to you. That's a "first."
Once you pass that threshold, it becomes a yes-and. You have enough time/money/resources/whatever to further invest in yourself, and invest in someone else. Yes, that means you're investing less in yourself by doing so, but you're still investing "enough" in yourself that you can spare the resources to help someone else out.
The tricky part is the definition of "enough" and where that threshold is, and what a "good" dividing line between self-investment and community-investment is.
The extremes are obvious and easy to answer. The inflection point is really hard and subjective. But people use the difficulty of the inflection point to avoid dealing with anything but the extremes, or else to argue that even at the extremes it's too hard.
Extremes: Below $10,000 a year income, you really, really should not be donating to charity. You should be on the receiving end. Asking those people to pay higher taxes is ridiculous. Above $10,000,000 a year income, if you're not giving a substantial chunk of money back to your society you're a selfish asswipe. (Whether that's ad hoc charity or properly managed taxes is irrelevant for the moment, and Luke don't you dare get side tracked by "taxation is theft" and that nonsense, that's off topic. :-P )
So, where between $10k and $10 million is the inflection point where you should start paying taxes/giving to charity/helping others? What qualifies as "substantial?" Those are the tricky questions, but the existence of those tricky questions makes it really easy for people to either avoid, or abuse, the extremes.
If you don't like that it's monetary, swap in any other less quantifiable metric and the same basic problem exists. Eg, time helping yourself and your mental health vs spending time helping a neighbor. The same rough outline of the problem exists, and the heuristics are no easier.
RE: Is It Selfish to Help Yourself First?