There are a couple of key differences between Taiwan and Ukraine which may not allow them to pan out the same way in a potential war scenario.
The first is geography: Taiwan is a tiny island that has to rely wholly on ship and air transport to bring goods into the country, including military hardware. A Chinese blockade on the island would absolutely cripple their economy and fighting capacity, and would make a war of attrition very easy to win. Only a US intervention through sea and air supremacy could break this (something China is aware of and has been developing their missile tech for this reason).
On the other hand, Russia’s war of attrition dragging out for so long and Ukraine still not folding is due to Ukraine sharing a massive land border with the rest of Europe and can still easily receive military hardware and economic aid through land trade. Russia also cannot completely blockade the country due to NATO encirclement, which is why choosing to not rapidly take over the country but instead just park their troops outside Kyiv back in 2022 to pressure the government was a massive strategic mistake.
The second difference is the politics itself: Taiwanese politics is not the typical left-right continuum and is more about Reunification vs Independence. This is represented by the KMT-led pan-blue coalition, and the DPP-led Pan-green coalition. While the Pro-independence DPP is currently in power (largely due to public perceptions of KMT corruption and being more socially conservative), the idea of independence is still not popular in Taiwan based on 2024 census. Most Taiwanese are just waiting out to see how the US-China Cold War plays out while still officially being the Republic of China.
Furthermore, a Chinese invasion would likely greatly embolden the KMT and push the public towards them (they could say something like “see? This is what you get for allowing the DPP separatists to move away from Chinese reunification, we will end this war by offering a quick peace with the PRC”). It also doesn’t help that America already signalled that they are more than willing to throw Taiwan under the bus if China forces their hand by bombing their semiconductor facilities. They didn’t do the same for Ukraine (at least until this year) because muh White Western civilization being attacked by evil eastern hordes.
Finally, Zelenskyy was able to stay in power by suspending elections and banning all opposition parties that challenged his pro-war/ pro-west narrative. The DPP is in no position to do that given much of the military is still loyal to the KMT thanks to the Chiang Kai-Shek military dictatorship-era, and trying to ban the KMT (which has a different foreign policy to the DPP) would very likely cause the KMT to seize power and declare marshal law with the backing of the military instead.
Tim Cook was not gonna let Trump cook his shiny fruit products