If you think about it, it's not. Coke has a great brand because their products pleased consumer expectations, just like Apple. Cokes brand is so good people won't switch even if given a potentially better product, because Coke has always tasted good to them, Sams Cola might not.
There is a significant difference between Apple and Coke. You always buy Macs because they are better for your workflow and find the experience delightful. That makes you usually want to replace one with another. You then have a bad experience with a Mac purchase. You now are far less likely to trust Apple and the Mac when you make your next of purchase.
Coke doesn't suffer the same problem. The joy of its purchase is the consistency of the experience, it's always the same. You know it will never disappoint that taste desire. That's why Coke never ever allows its bottlers to vary the formula even minutely. That way They can never lose your trust. If you drink it from fountain dispensers, your experience is less consistent, making that a more challenging market fir them.
So yes Apple is helped by branding. But like all great brands, Apples brand was built from product excellence, not advertising. Advertising is just a reminder or purchase trigger for the good feelings you already have for the brand.
"Yea, those AirPods look cool, that reminds me I wanted a pair because I expect them to work really well. I should do that now"