Three main options I see:
- Instead of trying, and failing, to take Rome, Carthage makes some gains and then agrees to peace with Rome. They agree to operate in different spheres of influence.
- After the 2nd Punic War losses, Carthage doesn't get involved in anti-Roman agitation in Hispania and Greece. Roman anger at this Carthaginian interference led to the 3rd Punic War -- the siege and destruction.
- Both Rome and Carthage simply focus in different directions so their interests don't so directly collide. In general, if Carthage focused on North Africa and Spain and avoided Sicily (and Sardinia), Rome and Carthage would have far less conflict.