Not sure I get the government analogy either.
OK, try this one. It's a "Loss leader".
The government does not make a profit from building roads. The government spends money on roads, but gets nothing back in return, modulo a few toll roads.
But the existence of roads means that we can go to work and make money, and sell things to people who want things, sometimes by them driving or biking or walking on those roads to get to a store. All of those activities generate sales and income taxes, far in excess of what it costs to pave the roads. Roads do make a profit in and of themselves, they enable a profit in a larger context. And really if you are doing it properly, you don't measure it in terms of the taxes generated down the line - people's lives are better because there are roads, and while that isn't measurable in a P&L statement, it can be worth investing in roads for people to have better lives. When I buy an ice cream cone and eat it, I now have less money, making it a bad financial decision, but I like ice cream and the benefit from getting that ice cream cone might be more valuable than the money.
The NBA loses some money running the WNBA, but the WNBA draws more people into the overall basketball ecosystem of the NBA, where the real money is made. And some of the return is just general goodwill. not measurable in dollars and cents (though that's probably a very small part of the motivation here).
The NBA is thriving. MLB not so much. Coincidence? The NFL is creaming themselves over Taylor Swift attending Chiefs games. Increases their bottom line.