Companies may use open source software but they don't directly or indirectly profit from it; they can only profit from the value they provide on top of it. Software that is free for everyone cannot be a distinguishing feature.
Contributing to open source software, even if used by for-profit entities, is increasing the total state-of-the-art for the entire industry. If you are demoralized by that then you probably want a job, not a hobby.
The other case is a project desperately needed by the community and every corporation is making their own internal version of that code. No one really wants to commit the next 10 years of their life to it but someone eventually does sensing the need. The author gets many stars and forks but almost no money. Corporations then want to twist the library to their own specific needs while an individual or small team build a necessary tool but there's no business model. Then either a corporation adopts the repo to keep it going or the author tries to turn it into a business. Both of these outcomes rarely succeed for the wider needed but no one's really willing to pay for it.
These are super broad generalizations. The big problem seems to be when some software is really needed, someone steps in to build it and then no one pays them. Need != business model.
I’m just pointing out that in open-source-as-a-hobby its very common that large corporations, who may or may not give back to the community themselves, derive profits off of hobbyist work while this is less common with other hobbies. Even if it doesn’t financially hurt the hobbyist, it can be demoralising (although others love it, so to each their own, I suppose — that’s why we have different licenses)