Practically the Romans never quite developed the phalanx and I think it didn't suit their needs and their way of being. They went for a new way of fighting and, of course, they were thinking out of the box, trying to be better than their neighbours. And their neighbours were pretty much influenced by Greeeks so naturaly the Romans had to invent a way of fighting phalanx style armies. The Roman formations, beggining with the Hastati, Principes, Triarii and ending with the Legions, were designed to beat the phalanxes and to be pretty good against whatever they should come up against.
Yes, the fact that the Romans didn't go into the whole phalanx based warfare thinking sysatem, hugely helped them to beat the Greeeks. On them beating the Carthaginians, that's a whole different issue.