I suppose you could make an argument the the US should only defend US flagged ships, which might save the US money or something. (I don't think I'd believe this argument, but you can make it)
Unless that ship is headed to the Gaza Strip: see https://en.wikipedia.org/wiki/Gaza_flotilla_raid .
Note that the budget of the country in question is what is really being talked about, and not the entire GDP of the country. It is possible for the US navy to save money while costing the average US citizen money.
You've just described mercantillism. Post Bretton-Woods is the first time in centuries the world hasn't worked that way. The dream of free trade and globalism was that everyone had equal protection on the seas. I fear you're correct that we're returning to a darker time where autarky reigns and trade is restricted to essentials.
A ship can be built, owned and operated from outside the US but still be registered in the US.
You may be thinking of the Jones Act, which implements cabotage in the US, a fairly common practice among seafaring nations: https://en.wikipedia.org/wiki/Cabotage
Meanwhile, attacks on EU vessels will likely attract sympathy for the attackers from the EU.
in this case it's pretty clearly the Houthi-let Yemeni government, which is a proxy for Iran, and all parties have been pretty vocal about it.