The empathetic perspective is that these CEOs and boards don’t have national allegiance. They are trying to optimize globally, and China is more exploitable in the sense of getting a steeper growth curve out of it.
The realpolitik perspective is that some countries demand allegiance from companies that operate on their soil (China), while others don't (USA). So Apple has a national allegiance to China in that country, and an allegiance purely to profit in the USA. It's easy to guess which country's citizens will receive more corporate philanthropy. See GP comment for the answer.