The perpetuating part of a two-party system arises from a "first-past-the-post" system. In a first past the post system, the natural course of events is for a dominant (majority) party to win elections, and a minority party to arise of all those who did not win. If the minority is too fragmented, there is no chance for them ever to rise to power. As such, the natural state of affairs is for the minority to ally and become more cohesive. In contrast, the majority party need only have 50% of the vote, so there is little incentive for the majority to keep changing positions in order to garner "more than 50%."
From time to time, the majority party will, for whatever reason, lose the support of the majority, and be forced to trade with the minority. This is a known equilibrium point - a bilatera equilibrium stasis.
In an electorate with a single district, the majority party is pretty much assured of staying together (it behooves everybody to get along and serve the majority) but the minority party is usually in a mode of seeking those issues that could overturn the majority. Because of this, there is less natural cohesion amongst the minority. Indeed, the history of the Federalists and the Whigs bears this out - not every minority party eventually returns to the majority.
When multiple districts with multiple ideologies are added to the mix, however, there is less certainty that a majority party will be majority everywhere. Indeed, in the US, again, the equilibrium seems to be that the South and Mountain West is mostly the domain of the national minority party (right now), and the West Coast / Northeast coalition of the majority party.
Because there are areas in which the nationally minority party can hold sway, there is a means of maintaining unity, even within the minority. As such, a federal system that already encourages two parties (first past the post) combined with a mechanism for maintaining cohesion in the minority party (regional areas with majority-minority districts) yield a very stable two-party system.