Accepting the principle that nuclear-armed states can invade their neighbors with impunity functionally guarantees that nuclear war will happen sooner or latter. Just like accepting Hitler's invasion of Czekoslovakia functionally guaranteed WW2.
The only way you actually stop it is by putting your foot down and saying "try me".
So the only way to stop nuclear war is to get into one? Makes no sense.
Taiwan is not Ukraine. Ukraine is an internationally recognized U.N. member state, including recognized by Russia itself until 2014, with its 1991 borders. Taiwan on the other hand is not recognized by any but a handful of tiny countries and has not even declared its own existence except as the Republic of China (ROC), let alone ever having been recognized by the PRC. So there are huge differences in principle between that island and other neighbors that are actual states.
Further, there are things we can do to defend Taiwan and deny "impunity" without getting into a direct war with China. We can impose economic costs like prohibiting Chinese exports which would cripple their economy, sanctions, and providing weapons and other aid to Taiwan that would make the attack prohibitively costly.