For me, open source is a matter of passion. If you like programming and you do it on your free time, at some point, you end up with a more or less showable software that is useful to you. Of course you will share it with others, thinking that maybe it will be useful to someone else.
Working to make money is a completely different story, and it's quite rare to be able to completely merge work and passions.
There are also plenty of reasons for a company to publish open source software (and that's a good thing!). But you have to remember that behind this choice, there will always be a strategic reason with a business plan.