Pretend I am a business owner who creates a wedding vendor venue where everyone can come and sell. I build the building and pay all the utilities. I want to charge people to sell in there. No problem.
Now I am forced to allow competition. No problem. Build your own building.
But NO....I am now forced to build sidewalks to the other buildings. Allow them to walk in a promote inside my building all why paying me nothing. And occasionally one of them comes in my building sick and makes everyone else sick and I get the bad press and get sued.
The analogy doesn't hold up. Look at macOS. It (like iOS), is built on a UNIX base, and thus the means and ability for software to install on it was built long ago before OSX existed, and not by Apple. Apple doesn't have to build and roads, pay any utilities, or provide any buildings. All it has to do is remove the roadblocks it put on the public roads (purely to funnel an obscene amount of Apple Tax into its coffers).
Now sure, Apple has indeed built up macOS with API's and tools that both Apple and non-Apple software can use. However, they don't charge companies to use it on macOS. Why? Because without those companies, such as Adobe, MS, etc writing those software packages, macOS would be useless, and no one would buy Macs. There is zero different with iPhones. If every external developer hadn't created any apps that can run on an iPhone, then no one would buy iPhones. THAT is what Apple gets from providing this infrastructure. Hardware sales.
The reason they do it on iPhones and not Macs is simply because when Macs were invented, they were merely yet another computer, and if they tried to do what they've done with iOS, then the Mac would have flopped. However when Apple introduced the app store monopoly into iPhones, iPhones were pretty much the only serious game in town, and apps via the browser were already abundant enough. They saw an opportunity to whack on a massive Apple Tax, and went to town on it. They got too greedy. And now the world is saying enough is enough.
Democracy is run by the people. Not the corporations. When a corporation annoys the people enough, it pays the price.