Google, out of all companies, also decided to partially walk away from the Chinese market in 2010 over censorship concerns [1].
Nobody is forcing Apple to do business in China, or the UK. They actively choose to do so, and because of that also put themselves in a position where they have to comply with these laws, presumably because it makes them more money.
[1] https://www.nytimes.com/2010/03/23/technology/23google.html