Buying an iPhone is like buying a Costco membership. The argument is that you buy the device for the app ecosystem. If you want a different app ecosystem, you buy a different device.
I mean, that is what Apple wants to sell you, but that's really no different than Ford saying "You have to buy Ford gas and tires because this is a Ford ecosystem", in which we've told the car companies to screw right off, though this is coming back with electric vehicles in a bad way.
One of the other arguments here is that when it comes to games I can get a Nintendo, or an Xbox, or a PS5, or a PC that I can run Windows/Linux games on.
When it comes to phones we pretty much have a duopoly which means both groups can find it easy to manipulate the market to higher prices without indirect (illegal) signalling.
Luckily it looks like the EU is telling Apple to suck it and they'll have to open up app stores on their phones.
All of those gaming platforms have platform exclusives though, and pretty clearly can exert significant influence on game developers due to their ability to determine what software runs on their devices. I'm not really sure how the duopoly of smartphones is significantly different than the handful of competitors in the gaming market.
There are thousands of competitors in the gaming market.
There is also a big difference between a company saying "I am only going to make this for the Apple app store" and saying "You can only have the Apple app store".
I would only make it illegal to sign an exclusive contract. The market would handle the rest, unless the platform they targeted had unique capabilities that other platforms didn't (e.g you game will only work with on a touch screen).
Buying a Costco membership doesn't mean you can only shop at Costco though. If Wal-Mart has a better price on X or if Mom and Pop shop has item Y that Costco doesn't carry you can still buy them.
And buying an iPhone doesn't mean you can't also buy an Android phone. The analogy you're looking for is that Costco does not indiscriminately allow all sellers to sell products at a Costco warehouse.