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".