Japan invaded through Manchuria in WW2 so it makes sense for China to have as big a buffer zone as possible in that area.
The border between china and afghanistan is very mountainous and very far away from Beijing.
For example: one of the most criticized of China behavior, that is the occupation of many parts of mongolian and related lands, is a way to prevent another Khan starting another Yuan dynasty.
Similarly China had many wars with Korea, and don't trust them (neither do the Japanese, thus why they don't move a finger to get rid of North Korea either, nevermind blatant racism in Japan, like the fact that nonasians can expect to get citizenship after about 20 years trying, while many second and third generation Koreans still aren't allowed to be citizens)
†Which would then crater a lot of everyone's economies as foundry chips, computers and their components get super scarce to unavailable for a long time....
China's industrial output is actually above the US's now: https://en.wikipedia.org/wiki/List_of_countries_by_GDP_secto...
A lot of this comes down to quality, which by and large neither the Japanese had at the time, e.g. an ability to built reliable airplane engines significantly more powerful than the one the Zero started out with, and as for the PRC, the latest tidbit in this area is their embarrassment that for all the billions of ball point pens they manufacture each year, they have to import the ball bearings, since they can't produce them in the quality required, at least not at the volumes required.
(On the other hand, their Long Lance torpedoes were an unpleasant surprise, and their torpedoes actually worked, or at least they quickly fixed whatever problems theirs' had (I've read in passing that all the naval power's torpedoes had problems at the beginning of the war, unfortunately the US Navy bureaucracy's total inability to believe field reports resulted in very bad results for more than a year). Then again, you didn't really need such fast and long range torpedoes, and they weren't decisive.)
And quality matters a lot in warfare. Just our nuclear attack subs alone could make an invasion of Taiwan ultimately impractical, unless they somehow figure out how to find them (and even espionage isn't going to be enough to target weapons).
For one thing, the de facto state of the world right now is that the US controls all the oceans. Being able to secure island chains and put area denial weapons on them would increase China's capabilities and also reduce the US ability to project power easily. That doesn't mean they wouldn't be swept aside in a real war, but they would impose a real cost on the US to get rid of, and that's the entire point.
NK is such a failed state that we keep on propping up its failed regime because no one knows what to do with its 25M citizens