The company wants to do business in the UK, it has to follow UK law. UK law claims for itself the right to act globally, and has the power to arrest and fine the companies and officers of Apple that are based in the UK if they don't… but then the Pope claims supremacy over all Catholics* and gets ignored somewhat in this also, and for the same reason:
There are other governments involved, and they don't accept the UK's (/Pope's) jurisdiction exceeds their own.
And in this case, the laws of other nations seem to require Apple to violate this law, so Apple's officers have to decide between which country to risk having arrest their officers, or to leave the UK.
(I have no idea what's going to happen, because the intelligence community in every nation has reasons to want Apple to be forced to do this, so if Apple decides to agree with the UK and violate other nations' privacy laws, those privacy laws may get conveniently ignored).