Energy prices are currently high b/c a lot is produced by gas powered plants, but as Germany peaked renewables at 82% lately, and new renewables are very cheap (there are solar plants popping up everywhere here), energy should not be a problem (chip production is not aluminium or fertilizer production).
The main reason TSMC builds there is that there are already lots of chip makers and knowledgeable staff to hire (and state subsidies, which if correctly used can be a good thing, Bavaria made the transition from an agricultural country to a high tech country with state subsidies, money transfers from the richer states in Germany to Bavaria - of course if used badly are just lost without effect).
This is one of the most annoying openings to a sentence you could device, just fyi
As to the why. (With the premise that the comment you're replying to is overstating it)
An open border is pretty irrelevant to all of the above, more relevant is that both are in the EU. So you can somewhat imagine them as US states on steroids. They set their own taxes with a large degree of freedom, devise their own policies with a large degree of freedom etc
- energy costs are a factor of market price and taxes, the electricity market is the same but taxes on energy can impact differently - land costs are fully dependent on factors that have nothing to do with open borders or the EU, just local/national taxes and zoning etc - water supply depends on the geography/geology of the area. I don't know if they're that different but I don't see why they couldn't be
There are a bunch of regulations on how companies can operate in the economic block, but it's still a bunch of sovereign countries there.