Earlier quoted context omitted.
by couldn't compete, i assume you mean, "didn't want to hand over all their IP to CCP, who would in turn give it to the native competitor", right?
No by couldn't compete, the OP probably means western tech companies do a remarkably poor job of understanding the Chinese market and frequently gets out innovated. When Google first entered the Chinese market, Google PinYin input lifted data from Sogou Pinyin because they couldn't get basic input prediction right. Baidu RankDex predates Google PageRank and was referenced by Larry Page when he submitted patent for Pa…
Despite continuous friction with the Chinese government, Google's share of the search engine market in China had grown to over a third before it decided to pull out: https://www.wsj.com/articles/SB10001424052748703465204575207...
Google hasn't pulled out of other markets where it faces strong local competitors, such as Yandex in Russia, and it remains popular in Chinese-speaking markets outside of mainland China such as Hong Kong and Taiwan. That the developers of the Google Pinyin input tool were found to have copied data (something other companies in and out of China have also been guilty of from time to time) is hardly evidence that Google in general was not competitive.
Ironically, the fact that under Pichai a return to China was seriously contemplated would suggest that financial reasons alone can't explain the original decision to leave.
Similarly, YouTube wasn't forced to pull out of other markets where it faced competition. Also, YouTube was frequently blocked by Chinese authorities even before Google decided to pull out: https://www.wsj.com/articles/SB10001424052748703465204575207...
Competition may explain in part why Google hadn't conquered the Chinese market before it left, but conflict with the Chinese government, in the form of official censorship as well as illicit hacking, would seem to be the main reason why Google pulled out of China but not elsewhere.
Unless of course learning to comply with such demands and intrusions is included under "understanding the Chinese market".