German car makers got lazy with research and development. In addition, they were hesitant to give up their investment in ICE production, risk staff reductions, and corresponding political and strike problems. This lead to most of the knowledge around EVs being developed and patented elsewhere, especially battery knowledge is firmly in Chinese hands.
At the same time the grandparent is also right, China wisely required knowledge transfers (in the form of forced joint ventures) in exchange for production and sales licenses. German car makers stupidly and greedily agreed, providing the Chinese with valuable knowledge about all the other parts of a car.
Both those mistakes now mean that Chinese companies have all the necessary patents and knowledge, as well as experience, for building EVs. Whereas German car makers will need to buy, license and beg for parts in China.
Not to mention that production in China will of course always be cheaper, and bureaucracy easier in the relevant circumstances.