Real world example: CiviCRM & GoCardless integration
I built a CiviCRM extension to integrate GoCardless (a relatively low-cost direct debit payment processor popular in the UK) for a client so they could benefit from cheaper regular gifts. Rather than just keeping that code for their use, I published it with an open source license and made it available to the wider CiviCRM community.
Now there are over 150 organisations using it. What's more, my client has benefited from improvements funded by other organsiations over time. And when an externally-imposed change occurred that required major changes, several organisations shared the costs. It has also been good for Artful Robot because many organisations have consulted us to help with their adoption/migration. Having all these interested parties makes the software more sustainable.