Is it a charity? It's the Mozilla Foundation and the Mozilla Corporation. Despite some explanations I've received, I've never quite understood how the money flows there. I suppose I could look up their financial statements, but my understanding is that if you donate money to Mozilla, it won't be directly used for developing software.
A charity can't function like a normal business. Income to the charity must be donations, and it's OK to give something of low value back but you can't just "sell" stuff and make money. Hence, "Donate $250 and get this T-shirt".
But what you can do is have a _for profit_ company that makes T-shirts and sells them for $10, and then a charity which _owns_ the for-profit company and receives all of the profits as a donation from the for-profit. That's legal.
So, Mozilla has a corporation to do all the stuff a charity isn't allowed to do, and then a foundation which owns the for-profit corporation. Getting paid a pile of money by a Search Engine to make their engine your default is not a charitable donation, because there's a quid pro quo, so the Mozilla Corporation takes all the Google money, for example.
I think I'd describe the situation you give as "charities can make and sell stuff for profit but have to structure themselves as owners of a for-profit in order to do so".
I'm not familiar with US charity law, but it's worth noting that a charity in the UK can '"sell" stuff and make money' the key thing is what happens to the money made, it has to be directed to the charities registered aims - eg paying staff. They can't disperse profits, but they can pay phenomenal wages, some charity CEOs take home 7 figure wages [£3M was the highest wage in 2017, to a non C-grade too, https://www.thirdsector.co.uk/charity-pay-study-2017-highest...].
There are restrictions, charity shops can't get reductions on business rates if ordinary selling is a large part of their income, for example.
Correct. If you donate money it goes directly to the Mozilla Foundation, whereas it is the Mozilla Corporation who hires developers to work on Firefox, etc.