The lawsuit side, genuinely asking, how does the for-profit under non-profit setup work? What are the respective roles? Is the combination effectively a non-profit still? Or is this some kind of legal loophole to make profits under a non-profit?

Lots of non-profits use structures like that, it's not uncommon. Non-profit vs. for-profit is mostly a legal and accounting distinction; many laypeople confuse "non-profit" with "charity" and they are very different.

The Mozilla Foundation owns the Mozilla Corporation. The Corporation hires the engineering staff that does the bulk of the work to develop Firefox (the rest are community/volunteer contributors and partners.)

I used to work for one. Probably not that similar, as one was a PBI. But one entity paid and billed back to the other. It was interesting to see how the way the 2 entities spent money differently.