Semiconductor Factories (called Fabs) are highly capital intensive and become obsolete after just a few years. Countries that provide tax incentives can really swing the decision of where to locate them. (Even within the US states/counties that offer property tax incentives are important.)
Also, historically these Fabs were not particularly environmentally friendly with the amount of water used and NOx emissions, but that is getting better. (One of the reasons there have been no new Fabs in California for decades, but instead are in Arizona, New Mexico, Oregon, New York, etc.)
Intel was historically Union averse, so I was surprised to see them pick Ohio for two new Fabs.
This offshore trend started 20 years ago with the decisions to build in Ireland and China.
Another issue is that even chips that are fabricated in the US tend to go to Asia for final Assembly/Test.