It is true that HoI fortifications are aimed at landings, but in reality they were mixed. Coastal artillery was an integral part of the defence of the landing sites and simultaneously could harm the nearby ships. At some locations it existed alone as well.
You present the coastal batteries as a liability rather than asset. There are some points to the contrary. First - they were not easy to disable, you need some heavy firepower to do that from the sea or considerable air force (remeber that major ships and strategic bomber units are a rare thing). Thus they made impossible quick opportunity landings from seaborne forces without heavy support. Second - they prohibited usual maritime traffic in the vicinity. Third - they could do some harm to the landing forces even if those were properly supported, or in least case provide time for reaction when enemy started to reduce them.
So they are perhaps not the most necessary element in HoI arsenal but their inclusion (with the effect on enemy ships) would be nice.
The problem is that they did not work except for in some narrow straights.
If you look at the actual landings that did happen during WW2, very few ships was lost due to coastal batteries. The guns where either destroyed or missed their targets.
Some batteries, like in Norway, did deny traffic within their effective fire range in good weather. BUT that was not a complete HOI sea province. And if the allied forces decided on invading Norway or if the area was important for allied shipping, you could rest assure these batteries would have been rendered inoperative.
The allied strategy concerning Norway was to make Hitler believe there where an invasion in the planning, in order to make him waste resources on fortifying Norway with things like coastal guns...
About how easy they where to destroy. The technology of bombing heavy fortified complexes made enormous leaps forward during WW2. In the beginning the gigantic steel reinforced concrete bunkers made for coastal guns and submarines where hard do destroy and required large number of bombers. But the development of things like the bunker busters and air mines changed that dramatically.
I found this quote at
U-boat bunker:
The protection offered by these bunkers were adequate throughout the early years of the war, until 1943 or 1944 when the Allies introduced the Tallboy and Grand Slam bunker buster bombs. These 12,000 and 22,000 lbs bombs scored numerous direct hits and several bunkers were penetrated. The response was to further reinforce these bunkers from between 3 – 7 meters to 7 – 10 meters, but up to the end of the war, these were never completed.
Those bunkers where at least as good as the gun bunkers. Also there is no need for complete destruction to make an gun battery inoperative. Even the blast wave itself often killed the crew and dislodged the equipment.