Apple is, from a purely practical standpoint, more a Chinese operation than an American one.
Additionally, the humans who make all of the iPhones and iPads are Chinese people, subject to Chinese law. Apple has to do exactly what the CCP wants, at least for now. They are desperately trying to ramp up phone production in India, but there is huge expertise at Foxconn that isn’t in India as yet.