They were not tank traps.
They were beach obstacles designed to tip, puncture, and destroy landing craft approaching the beaches. there were several kinds, but you are probably thinking of the one called log ramps, although many were made of steel beams. They were supposed to be beneath the water at high tide and cause landing craft to run upon it, tip over and be unable to pull back off. A landing craft on its side cannot drop the bow ramp to unload equipment and is vulnerable to gunfire.
Source: Jay Snead (Quora)