Earlier quoted context omitted.
Many countries including China do block US companies on national security grounds. National security is very much a double edged sword.
US companies operating in China need to follow Chinese laws, including those on censorship. Google etc are blocked because they are hosted outside China, and are not willing to cooperate in China. What I find bizarre about the Tiktok ban is that they are being banned essentially on executive whim: as far as I can tell, there are no concrete allegations, much less evidence, that they're violating any US laws.
Be noted that China is not a country under rule of law.
When Google was blocked, there was no primary legislation stipulating that online content shall be censored in whatsoever way. There were vague administrative rules (secondary legislation) with questionable applicability. Today, there is only one piece of primary legislation with a section on online censorship in China, but this section targets ISPs only, not content providers.
EDIT2: corrections