Would have Apple done the same if it was any another country?
Probably not. They would have courts and the democratic processes to help them resist.
But in face of authoritarian government who can hurt Apple's sales the company always bows. Be it actions in China or now action in US. The motive is simply profit.
The company cannot have a centralized control to make it "safer" and then give that way if the profits are under threat. Companies should be shamed for that.