Please go read China's GDP and try to understand how it would completely crash if they went to war with the US. We're far too dependent on each other to go to war over anything.
I stopped relying on rationality of humans when it comes to war.
Russia and Ukraine had terrible birth rates before the war and Russia had a clearly inadequate amount of soldiers for occupying a country of that size (only about 200 000, where a million or more would be realistically required). Not very good preconditions for a massive war. Putin went ahead anyway.
GWB's attack on Iraq wasn't a particularly smart action either.
Maybe China can learn from those mistakes. Or maybe Xi feels that his time is slowly coming to an end anyway, and a Heroic Feat is necessary to fix his position in the textbooks of tomorrow.