The second condition, وَإِنِ اسْتُغْنِيَ عَنْهُ أَغْنَى نَفْسَهُ, addresses the opposite situation. If others do not need his help, he remains self-reliant and does not impose himself on them.
This is not a call to withdraw selfishly from people. One should help when genuinely needed, yet avoid seeking influence or attention when one's involvement is unnecessary.
اسْتُغْنِيَ is a passive past verb. In أَغْنَى نَفْسَهُ, نَفْسَهُ is the direct object. The two conditional clauses teach balance.