Well because 45%+ of its exports go to the EU.
And the EU is not just a trade deal. It is a single market, like the US is a single market, with a great degree of regulatory uniformity. Which means accepting laws from a central source (in the US it is Washington, in the EU it is Brussels).
What you think would happen to Texas were to secede? With border controls? With its internal regulation for its market? Paying tariffs to access to the rest of the US? No free-movement of people? And all of this, and we have Florida, right next to Texas that just remains in the US; why invest in an independent Texas if you can invest in Florida?
(Of course the EU is not like the US. The EU is a very thin federal layer compared to the US federal government. e.g. EU states go to war on their own all the time.)
The UK might get a Switzerland like deal. But that is very close to being a full-fledged member. That is not a hard-Brexit.