How is it legal for a non profit have a for-profit subsidiary?
They just can't "profit" in terms of paying that extra out to owners. They have to reinvest back in the org, pay it out as salary, or play financial games with it.
It does not mean they have to operate on razor thin margins and struggle to survive every year. They can (and should) have warchests that can cover a few bad years or longer.