Specifically fortifications meant to damage or destroy incoming hostile ships.
The Punic Wars must have involved a lot of navies landing troops, were there fortifications built to prevent or deter such landings? What about for use against Viking raiders during the 900s or to protect straight crossings later on?
Your question assumes some things that aren't really correct. I imagine you're thinking of something like this scene from Troy which is, of course, fictional.
Fortifications definitely existed in the pre-gunpowder era. It also was not necessarily uncommon for fortifications to extend down to the waterline. See, for example the ancient walls of Acre which date to the 10th century or so, or the sea walls of constantinople from approximately the same era. Many other cities did have "sea walls" but these only really served to keep an invading army from circumventing the fortifications by approaching from the sea. They did not actively count as "naval fortifications" like I think you mean. They weren't targeted at ships, but merely to keep men in an invading army from coming in on the beach vs coming in on the land.
It's much rarer to see defenses specifically targeted at ships. One example that does come to mind is the fabled "great chain" of constantinople. Constantinople guarded the bosporus, the connection between the Mediterranian and the Black Sea. The city is built on a peninsula and surrounded on three sides by water. On the north side of the city is the "golden horn" a long inlet that also serves as the city's primary harbor. An iron chain was made and strung between the walls of Constantinople and the Galata Tower on the north bank of the golden horn to keep ships from entering the bay.
Edit: parenthesis in title of picture from wikipedia screwed up the link and I don't recall how to fix that, so here's a direct link to the article. Picture is embedded. It's a surviving fragment of the byzantine chain. http://en.wikipedia.org/wiki/Galata_Tower_(old)
However, the chain demonstrates very well why fixed naval fortifications just weren't a big deal in the ancient world, and ancient coastal powers tended to rely on their navies if they wanted to actually protect the cost, or retreated inside fortified cities if they didn't.
During the Rus-Byzantine wars in the 10th century, the Kievan Rus sailed longships down what is today the Volga River and into the black sea to attack Constantinople. The Byzantine empire had news of their coming, and sealed the city up. The vikings found the city sealed up tight and the harbor barred by the chain.
So what did they do? The folklore stories talk of Oleg constructing "boats with wheels" but the reality is likely a bit more pedestrian. The leader of the viking band simply landed his longships on the coast slightly up from the chain, and had his soldiers portage them across a few hundred yards of land, then re-launch them inside the golden horn. The byzantine navy then destroyed the ships with fire based weapons.
The same is true almost anywhere else you look in the ancient world. Ships are mobile. A ship at sea can easily move faster than an army, and with good wind can even move faster than a cavalry force when you count rest time into the equation.
The range of weapons that could be used was also very short. When weapons can only fire a few hundred yards it's not difficult at all for ships to simply remain out of range.
So in the ancient world, a naval fortification in the sense you're talking about makes little sense. If you set up naval fortifications on the coast, the invading army is simply going to sail 5 miles up the coat and land there, then march their soldiers down to the city and attack it from the land.
If you want to stop the enemy before they land in your territory, you build a navy. Ancient Athens was famed for its navy which defeated the Persians on more than one occasion. They referred to the navy as the "wooden walls" of athens. When you fight an invasion force with your own navy, you can to some extent, pick the time and place of your engagement.
I was going to mention the Byzantine Chain as well, but because it makes something quite clear. An iron chain was all it took to stop a navy from causing any substantial damage to the fortified city of Constantinople. Prior to gunpowder, and particularly prior to John II of Portugal fitting many of his ships with heavy weapons, land fortifications were proof against most anything mounted on a ship. Byzantine fire weapons (and fire in general) could be a serious danger against wooden fortification, but high stone walls had to be breached by infantry, one way or another.
Antiship fortifications become important when the ship itself becomes a siege weapon. Until that point, ships were more troop transport than anything else.
I can answer that for the viking raiders of the 7th and 8th centuries often used rivers to come inland rather than coming directly from the sea and onto the shore, unless the city/village/monastery/whatever they were raiding was right on the coastline, in which cases there were no defenses besides walls and men. The only real known defense against the vikings' traveling rivers was the building of bridges that were too low to the surface of the water for the vikings' ships to safely pass under, which was often more of a coincidence than something done on purpose for defense. Oftentimes the vikings would simply tie ropes to the earthen foundations the bridges were set in, tie the other ends to their ships, and row quickly downstream, tearing the bridges away. On the occasions where the bridges were too strong to be torn out, the vikings would either a) turn back because their numbers were too low to siege, or b) they would lay siege to the city the bridge was located. One such case of this was the Siege of Paris in 885-886, in which the viking raiders laid siege on Paris. In this event, the vikings nearly gave up and left after being repelled by the small number of men led by Count Odo of Paris, only for the army of Charles the Fat, one of the rulers of the Kingdom of Franks, to arrive and Charles to allow the vikings to pass Paris and raid Burgundy, which was at that time rebelling.
Other than bridges, occasionally chains and ropes were thrown across rivers, sometimes stopping the vikings, even if only temporarily. In general, the vikings were a terrifying, nearly unstoppable force and not much could be done to prevent their landings.
Info from the book "The European World, 400-1450" by Barbara A. Hanawalt.
Edit: Thought I'd add a bit more.
In general, the style of fighting of the early Medieval Age didn't involve much amphibious landings right outside of cities, which is really why not many permanent defenses were purposely made against ships. Most kings, lords, counts, fiefs, etc. were too busy fighting land battles amongst themselves to really focus on the viking invasions, which often happened unexpectedly and almost randomly.
Hi! I'm by no means an expert but I'm taking a Roman history course right now and we briefly discussed the Seige of Syracuse during the Second Punic War. Archimedes was in command of the city's defense and he had a few ingenious methods to divert landings. Granted, most of them didn't exactly work out as planned and he died in the ensuing sack of the city.
One device was a large concave mirror that was intended to focus the sun's rays into beams that could ignite ships stationed in the harbour. Another was a claw-type contraption that could grab hold of ships that neared the city's walls, hoist them into the air using a counter-balance and then drop them. I'm not too familiar with standard sea defenses so if anyone has anything to add or correct, feel free!
https://www.math.nyu.edu/~crorres/Archimedes/Siege/Livy.html http://www.lookandlearn.com/blog/30947/archimedes-died-devising-new-defence-strategies-for-syracuse/