If the company's business is not software, they get the benefit of being able to use the software generated to improve their business.
It's a win-win situation - furthermore, as I said, the costs of development and quality assurance are dropped dramatically by participation in an Open Source project, rather than by doing everything in a proprietary manner.
Regards, Ivan
They are compensated by not having to maintain the software themselves. As an example take Samba and IBM;
IBM could have went out and created yet another SMB suite an then had to maintain it but instead they went out and hired the Samba development team to do the enhancements IBM felt it needed. IBM by doing this saved a ton of time and money and it does not have to forever be the sole or primary maintainer of Samba its an open source product..
Its not the best business model in every situation but it does often work for everyones benefit..
Because they USE the software, not sell it. Where I work, we have a lot of programs developed in-house that are not sold outside the company, but are used solely for internal purposes.