They don't have to. Building a semiconductor fab is such an enormous investment and requires so much specific knowledge that it's not an attractive option, orders of magnitude harder than copying some software.
A similar question would be how Airbus prevents airlines from building their own airplanes.
As I understand it from my time at AMD, TSMC provides what is essentially an SDK for specifying how to use their process for a given node. Clients translate (compile) their higher level specifications into this framework for fabrication, and own responsibility for characterizing (testing) the resulting silicon.
This separation of responsibilities presents TSMC with a difficult reverse engineering challenge if they were interested in violating their NDA.
I don't think that TSMC is really in a position to Sherlock their customers:
- Buyers of leading edge fab services have patented features in their chip designs which TSMC would violate by simple cloning.
- If TSMC wanted to profitably manufacture something like "a modern GPU, but avoiding existing patents" they'd have to expand massively beyond their current core competency of fabrication. They'd need experienced chip designers, software engineers for developing drivers and APIs, retail partners... it's a much different business.
The key thing that makes "Sherlocking" easy is that it's just imitating third party software with first party software, from a first party that is already good at making software.
A similar question would be how Airbus prevents airlines from building their own airplanes.