Then how does Apple not? Android lets you install other stores and lets you side load. Neither of which does Apple do.
Android is an open platform by design. So anyone can develop their own app store / app distribution system. Anyone can use Android and customize it for the hardware they develop. But what Google did was secretly bribing the phone manufacturers to preload Google Play services and Google Play store as uninstallable system service and app and make agreements that the manufacturers will never resort to any other app store. They are being punished for this behavior.
In case of apple, their ecosystem is closed, i.e. there’s no competitor by design. Moreover, one can’t legally access iOS without an iPhone. According to Apple, just the physical hardware of an iPhone isn’t a product they sell and shouldn’t be considered as such, instead iPhone(Physical Hardware) + iOS(which includes their app store) is one complete product which they sell. As a manufacturer of this product they are free to do whatever with the product they develop and not necessarily have to provide access to 3rd party in their product development process.
TLDR: Apple’s argument was if there’s no competitor by design then there’s no anti-competitive behavior for the court to judge.