Ummm... by producing well-made products that people like and want to buy?
People simply don't understand this. If the product doesn't work and they're unhappy then the ecosystem and other stuff doesn't matter. They'll stop buying that company's products. Period.
But Apple makes good products. The iPhone is pretty much best in class. The iPad? same. The Watch? Same. And the M1/M2 Macs? Doubly so.
And yes, they work well together. It's what I'd expect from Apple.
Will another product from someone else slot in and work seamlessly? Nope. And I wouldn't expect them to do so, anymore than I'd expect an iPad to slot seamlessly into a Samsung or Pixel or Amazon ecosystem.
As to the rest, if you're number one you have no need to compare yourself to competitors. Why give them air? Whereas when you're NOT number one, like say, Samsung or Pixel, then you in fact attempt to make comparisons and show that you're better in some regard. I mean, that's Marketing 101 stuff.