Carthage had Hannibal, but Rome had its institutions:
It was simply improbable that Carthage could win a military conflict with Rome over the long run because the Roman system conferred upon the Roman state material and ideological advantages which could not be overcome by military victories, even by a general as creative and competent as Hannibal. The Hellenistic king Pyrrhus learned this, and gave us the term “pyrrhic victory”. In ideological terms Goldsworthy argues that the Roman mindset was one where conflicts were viewed as wars of attrition, where only the victors were left standing. In contrast Carthage, like the Hellenistic states, operated in a more classical Westphalian framework where victory and defeat were never final, but simply instances of a continuous game between elites of distinct polities. But, if it was not for the material advantages of the Roman system its ideological orientation would have been suicidal, because wars of attrition can only be maintained when there are resources to feed them. The Romans relied upon conscript armies of free peasantry, committed to the idea of their republic as an expression of collective will, as well as Italian allies of long standing. Goldsworthy notes that no individual of the Roman elite betrayed their city, nor did any of the Latin allies (the cities who went over to Hannibal during his years in Italy tended to be culturally distant from Rome, whether non-Latin Italian or Greek). And, the citizen base of Rome was notoriously broad, because the Roman system was expansive, assimilating allies and elites of foreign polities over time. This is an ancient feature of Roman society, as at least half of the major patrician lineages are not Latin, but Sabine. This is in contrast to organization of Hellenistic or Carthaginian polities, which were not assimilative, but multicultural and cosmopolitan in a manner more resembling the later Roman system of the imperial period, or empires more generally.* The armies of Carthage and the Hellenistic kingdoms were not manned by citizens, but professionals, whether a standing army, or mercenaries and subject peoples. The army deployed by Hannibal consisted of Libyans, Spaniards, and assorted Italian peoples inimical to the Romans (e.g., the Gauls of the Po valley). Until the last of the conflicts between Rome and Carthage, which took place in the immediate environs of Carthage, Roman amateur soldiers lined up against armies in the service of Carthage, not armies of Carthaginians.
The robustness of the Roman system to defeat can be put down to the fact that like the armies of the French Revolution Rome threw its citizenry against its enemies to complete a broad mission, while its contemporaries purchased smaller professional armies to achieve specific tasks. In many circumstances these professionals could obtain victory, but the gains did not have the depth to force the concession of the Roman state, because the state was an expression of the populace, which remained defiant.