Over dinner a few years ago, the late John Dingell, who served in the House of Representatives longer than anyone in history, described how Congress had changed during his career.

When he arrived in the House from Michigan in the 1950s, he said, members saw themselves as, first of all, representatives of their state, secondly as representatives of an institution (the House or the Senate), and only third as members of either the Democratic or Republican party. Nowadays, he said, the order has reversed: Lawmakers see themselves...

Over dinner a few years ago, the late John Dingell, who served in the House of Representatives longer than anyone in history, described how Congress had changed during his career.

When he arrived in the House from Michigan in the 1950s, he said, members saw themselves as, first of all, representatives of their state, secondly as representatives of an institution (the House or the Senate), and only third as members of either the Democratic or Republican party. Nowadays, he said, the order has reversed: Lawmakers see themselves as members of a party first, and as representatives of their institution and their state only after that.

The polarizing effects of this evolution will be on display in Congress again starting this week, as lawmakers try to perform their most basic tasks: prevent a government shutdown by passing a spending bill, and prevent a national debt crisis by raising the debt ceiling.

The party-first mentality was even clearer before Congress broke for Thanksgiving, when it finally passed a big bill funding improvements in the nation’s infrastructure system. Though leaders of both parties have been clamoring for an infrastructure bill for years, the measure passed the House almost entirely with Democratic votes, with some members casting votes that appeared to be against the interests of their states and districts. That was followed by the spectacle of some Republicans calling for punishing the 13 GOP colleagues who dared to vote with Democrats to pass it.

For a good illustration, look at Mr. Dingell’s home state of Michigan. If any state needs an infrastructure upgrade, it’s Michigan. The American Society of Civil Engineers gives the state’s infrastructure an overall grade of D+. As the nation has seen, some locales in Michigan can’t even deliver safe drinking water to their residents because of the sad condition of aged water pipes.

Yet when the bill came to a final vote, six of the state’s seven Republicans voted against it. Nor was the phenomenon limited to Republicans. Democratic Rep. Rashida Tlaib also voted against it, in part because Congress wasn’t also passing a giant social-spending and climate-change package that she and other progressive Democrats have been demanding.

It’s possible the two parties are slowing destroying themselves with hyper-partisanship. And while there are a lot of root causes, a big one is playing out anew, right now.

Debate on infrastructure legislation has been along party lines, with some lawmakers casting votes that appeared to be against the interests of their states and districts.

Photo: C-SPAN

It’s gerrymandering—that is, the process in which state legislatures draw up House districts designed not to be representative of the population of a certain area, but rather to be perfectly safe for representatives of one party or the other by packing together Democratic and Republican voters into essentially segregated enclaves.

Achieving this involves drawing district lines so creatively that many members of Congress never have to worry about being defeated by someone of the opposite party. As a result, they never have to listen to someone from the other side, either at home or in Washington. In fact, the only real danger to the job security of representatives from these districts is to offend the party activists by compromising with the other side, which might produce a primary challenge from within their own party.

In short, it’s a practice in which politicians pick their voters, rather than the other way around.

It’s isn’t only gerrymandering that produces this effect. To some extent, Americans have self-segregated by moving into areas where they are surrounded by those who share their cultural and political feelings.

But gerrymandering is making the process of building fences between Americans much worse. And right now it’s under way anew, as state legislatures use the results of the 2020 census to draw new congressional maps. It’s an ugly spectacle. The nonpartisan Princeton Gerrymandering Project is grading state districting maps as they emerge for fairness, and it already has given F grades to Ohio, Illinois, North Carolina and Texas.

Both parties are complicit, but because Republicans have more power at the state level—they have full control of both the legislature and governor’s office in 23 states, compared with 15 for Democrats—they have the advantage in this process.

Republican lawmakers in Nevada, dissatisfied with Democrats’ redistricting plans, presented alternative maps this month.

Photo: Samuel Metz/Associated Press

It doesn’t have to be this way. California, of all places, may be showing the way out. California used to be the champion of composing safe, gerrymandered House districts. Between 2002 and 2010, California, with its 53 House districts, held 265 House elections, and there was a change in party hands within those seats exactly once.

But then a decade ago, thanks to a ballot proposition, a citizen-led commission took the task of drawing congressional districts away from the state legislature. And, wonder of wonders, more competitive districts have emerged.

Between 2012 and 2020, seats changed party hands 18 times. Gerrymandering puts lawmakers in hardened partisan silos; maybe California is showing how to break them down.

Write to Gerald F. Seib at jerry.seib@wsj.com