I don't think China would do a direct military attack on Taiwan. I think they would blockade it with their navy. That would put the shoe on the foot of either Taiwan or the western countries to fire the first shot.
Why did China suddenly decide in the past few years to suddenly build a Navy that rivals the entirety of the US Navy? Why did China suddenly start building 3 aircraft carriers?
This all coincides with the 100-year anniversary of the CCP (2021) and of the PRC (2049). We know they like a big spectacle, we know they like wolf-warrior diplomacy. And... there's in fact a chance that they can beat the USA's Navy in this scenario. Given that chance, and the prestige associated with such a win, why wouldn't China try? (No, they can't rival us on the open seas. But "home turf advantage" means China's Navy will be operating in collaboration with its Air Force and missile-forces. In contrast, US Navy + US Marines will be the only thing reasonable to deploy to help Taiwan).
It all comes down to the confidence behind those "hypersonic ship-killing" missiles China has recently developed. If they think they can kill the US Capital ships, then they've pretty much won the fight. The carriers are the cornerstone of our naval strategy, and the airplanes on board would be necessary for helping Taiwan in almost any scenario. If our carriers are dead (or threatened to leave the area), China probably wins. (US Submarines may be effective... but submarines don't project force into Taiwan, so Taiwan's army would be on their own)
It all comes down to whether or not our AEGIS Cruisers can shoot down those missiles. A completely untested scenario. 3000mph hypersonic is really fast, and will be a challenge to shoot down.
------------
Remember: China's official stance on Taiwan is that Taiwan is in rebellion, and that Taiwan rightfully belongs to China. The US official stance is ambiguous, we haven't officially declared official support of Taiwan. The diplomatic route would be for the USA to give up Taiwan without a fight, much like Hong Kong's democracy disappeared overnight with very little said/done about it. I have my doubts that the USA will give up on Taiwan like we did with Hong Kong though.
Korea, different topic. Any attack there would mean running over 50,000 US soldiers. Korea could be blockaded too though.
North Korean artillery has a range of 40 km (standard round) and 60km (long-distance round). Seoul is 23km from the DMZ. The entire city would be leveled with only artillery strikes, no such "North Korean invasion" needed at all. Furthermore: its a well known fact that North Korean artillery positions are heavily fortified, designed to withstand a nuclear attack from the USA (Korean War was post-nuclear after all). Only a direct assault with land forces would deal with that entrenched artillery. As such, North Korea can easily level Seoul in its entirety.
Those 50,000 US Troops are there to
invade if this scenario occurs. They'll be racing against the clock. North Korea on the other hand, just sits back and watches their artillery do all the work.
The only defense is a strong offense. But there's reason to believe our offense simply isn't capable of saving Seoul, or other major cities within 40km of the DMZ. We will probably win the war, but North Korea has many options to really hurt South Korea if it decides to go 100% crazy suicidal on us.
I have very little confidence in the ability to save South Korean cities in this scenario, but I have high confidence in "winning" in the long term, after months or years of combat. (Where "winning" is removing North Korea's ability to conduct such strikes again).
------------
Bonus points: the two scenarios can happen simultaneously. If North Korea decides to attack South Korea, China almost certainly will take advantage of US-weakness and use that as the time to attack Taiwan. Our military forces in the area would be forced to choose between helping South Korea or Taiwan. We will probably try to save both, but... its not like China is stupid about these things. They're savvy and opportunistic. They'll take any advantage they can get.