Why?
TSMC was likely threatened by Trump to invest in America. TSMC likely didn't want to do this. However, because they will have more fabs in the US, they'll likely avoid the tariffs as part of the deal. Further more, TSMC will still make chips in case of of a China take over. The risk here is that the US will simply confiscate TSMC's fabs if China uses military action on Taiwan based on security measures. That's the worst case scenario for TSMC.
For Taiwan, it's a terrible deal because the money is not invested in Taiwan and the island becomes less important in the world. The "silicon shield" would also be broken and the Taiwanese government has zero control over fabs in the US.
It remains to be seen if this will truly happen. Perhaps TSMC will always keep its most cutting edge node in Taiwan. Perhaps they'll drag this out over the next 4 years in hopes that Trump's party gets voted out.