If those products and services are unrelated business income, they have to pay taxes on it:
https://www.irs.gov/charities-non-profits/unrelated-business...What counts as “related” to the charity’s mission is fuzzy but in practice the courts have been rather strict. They don’t have to form for-profit subsidiaries to pay those taxes but it helps to derisk the parent because potential penalties include loss of nonprofit status.
For example, the nonprofit Metropolitan Museum of Modern Art has a for-profit subsidiary that operates the gift shop. National Geographic Society has National Geographic Partners which actually owns the TV channel and publishes the magazine. Harvard and Stanford have the Harvard Management Company and Stanford Management Company to manage their endowments respectively. The Smithsonian Institute has Smithsonian Enterprises. Mayo Clinic => Mayo Clinic Ventures. Even the state owned University of California regents have a bunch of for-profit subsidiaries.