That's capitalism, baby! It turns out domestic chip fabrication wasn't competitive (in this case a rare double-whammy of failing to compete on both cost and capability). The global market determined that Taiwan and South Korea made the best and cheapest chips so that's where all the manufacturing went. Demand for semiconductors is overwhelmingly not created by the military so it doesn't really make sense to compare it to submarines.
> Demand for semiconductors is overwhelmingly not created by the military
That may be true, but semiconductors are absolutely crucial to the military. I suppose the military has their own fabs locally located in partnership with Intel, AMD, IBM, TI, etc...