The Carthaginians were famous for their navies, and I dont see why he had to go through the alps. He lost half his troops after all. He might have been able to take rome if he hadn't.
On that point, its a wonder rome didnt experience more sea invasions. The last sea based invasion I know of was from King Pyrus.
u/XenophonTheAthenian answered this question regarding Hannibal a few years ago here and does a great job of hitting all the key marks - essentially:
One thing I'd like to emphasise is that, even though a journey by sea was a non-starter, that didn't mean that a land invasion was hubristic or a stupid idea. Here's Polybius (Histories 3.30), for instance:
Hannibal, after taking all precautions for the safety of Africa and Spain ... had informed himself accurately about the fertility of the land at the foot of the Alps and near the river Po, the denseness of its population, the bravery of the men in war, and above all their hatred of Rome ... He therefore cherished high hopes of them, and was careful to send messengers with unlimited promises to the Celtic chiefs both on this side of the Alps and in the mountains themselves, thinking that the only means of carrying the war against the Romans into Italy was, after surmounting, if possible, the difficulties of the route, to reach the above country and employ the Celts as co-operators and confederates in his enterprise. [1]
In other words, he knew that he would be effectively cut off from 'home' once he arrived in Italy, by whatever means - this was both a shrewd logistical calculation and perhaps a recognition that powerful forces in the Carthaginian state were bitterly opposed to him, the power of the army, and the war [2]. It was therefore vital that he gained local support, and knew that recent trouble in the area (the Gauls on the Italian side of the Alps had revolted, and been brutally suppressed, in 222 BC) would help him make alliances against Rome among the people he would encounter on a march across the Alps. It's estimated - though estimates of ancient troop numbers are always a bit hazy - that Hannibal had around 16,000 Gallic infantry with him by the time of Cannae, equivalent in number to the rest of his infantry put together [3]. Livy and Polybius both report several points during the crossing that he used local tribes to replenish supplies, and this no doubt continued while in Italy. So there was a very good military reason to take the overland route - it was the only way to generate the logistical lifelines that, given Roman sea power and domestic political uncertainty, could not be relied upon to come from Africa.
There's a broader question here about granularity in history - people tend to lump events in the past together, and to lose the sense of just how much things change over time. The picture of Carthage's dominant navy fits for the early stages of the First Punic War, which was fought between 264 and 261 BC, and the Second Punic War only started in 219, forty-two years later. Technology may not have changed as quickly as it does today, but political circumstances absolutely could. It's important not to get sucked into monolithic conceptions of what 'the Carthaginians', 'the Romans' or even 'the Ancients' were like - most modern studies of the Classical world emphasise how diverse it was, both over time and in different places, and many misconceptions and misguided interpretations arise when scholars fail to take sufficient account of that diversity.
Sources and Notes
A very good book that gives the story of Carthage and its wars with Rome from (as far as this is possible) a Carthaginian perspective is David Miles (2010) Carthage Must Be Destroyed.
[1] The big unspoken question here - which goes for almost everything we have about Carthage, especially in terms of political, military and diplomatic history - is how much Polybius (and our other major sources, Livy and Plutarch) really knew about the events in question. We know very little about Polybius' sources, though he does (at 12.25) give 'the analysis of documentation' as the first duty of the historian, which implies that he did have access to primary sources (likely in part through his friendship with Scipio and therefore association with the Roman elite) and generally lead his research with them. In 3.33, he mentions having found a bronze tablet 'on the Lacanian promontory' (presumably in Spain?) where Hannibal had recorded the composition of his army, and there seem to have existed Carthaginian works of history which were likely to have been accessible to Plutarch as well (see the answer from u/ScipioAsina here). Of course, you can then go down the rabbit-hole of how genuine and reliable these second-degree sources were, and at that point I think we just have to acknowledge that we're working with what we've got.
We also have the advantage that Polybius (unlike many and perhaps most Classical historians) explicitly disavows the practice (at 2.56) of inventing speeches to illustrate a moment, or adding details to augment the tragic force or moral messages of the narrative. By and large, he seems to have lived up to that - he does quote verbatim from treaties, and often passes up the opportunity to write a speech, or quotes one (such as that of the Rhodian ambassadors in Book 21) which is so bad that he could hardly have invented or embellished it.
[2] What I'm alluding to here is the political split between the so-called 'War Party' or 'Barcids' (named after Hannibal's clan) and the 'Peace Party' led by Hanno and Hasdrubal Haedus. On this see Miles 2010: esp. 286-288, which recounts an archetypal case originally reported in Livy 30 of the rationale behind the split, while also pointing out that the 'Peace Party' were quite happy to ride Hannibal's coat-tails as long as he kept winning.
[3] The estimate is from Gregory Daly (2001) Cannae: The Experience of Battle in the Second Punic War, p31-32 - though he notes that we have only very unreliable Roman estimates of Hannibal's strength, and takes issue with the general Roman supposition that the Carthaginians were outnumbered about 8-5 by pointing out that Hannibal's tactics at Cannae (allowing his centre to give ground, pushing forward on the flanks, and then enveloping the Romans) only really make sense if the two armies were roughly equivalent in strength.