What we, living in democratic societies, fail to appreciate is that autocrats don't mind destroying their economies in order to pursue their personal ambition. Putin has no qualms about sacrificing tens (hundreds?) of thousands of ordinary Russian men to secure his status as a great historical figure. The Russian standard of living will decline as it descends into a totalitarian state, but Putin and those around him have no elections to face. Even if the disastrous Ukraine invasion had been successful it would not have improved the lives of ordinary Russians, but it would have secured Putin's legacy.
The same goes for Xi Jinping. The Chinese Communist Party is no longer "Communist" in any Marxist sense, except in their rejection of democracy. As economic growth stalls, Xi is turning to xenophobic nationalism to bolster his legitimacy. The Chinese people will in no way benefit from an invasion of Taiwan. But Xi and the CCP aren't looking out for the benefit of the Chinese people, they are looking out for themselves.