Michael D. Barnes is a Democrat. So is Michael P. Barnes.

Michael D. Barnes is interested in politics, doesn't like President Reagan, and supports a mutual freeze of nuclear weapons. Same with Michael P. Barnes.

The main difference between them is that Michael D. Barnes is already a Democratic congressman from Maryland, while Michael P. Barnes is an aspiring one from Indiana.

So today Rep. Michael D. Barnes of Maryland's 8th District, who says he is "totally comfortable campaigning for Mike Barnes for Congress," will travel to Indiana to speak at a fund-raiser for Democratic congressional candidate Michael P. Barnes.

Although the Barneses have never met, 36-year-old Michael P. Barnes invited 41-year-old Michael D. Barnes to the fund-raiser in South Bend after reviewing the Montgomery County Democrat's congressional record and discovering that the two have similar ideologies.

"There is a little gimmickry to it, but you have to agree with people on their positions, too," said Sanford Brook, an aide to Indiana's Barnes.

Besides being lawyers, fathers of two children, and Democrats, Barnes and Barnes have similar positions on the economy, defense spending, and the Equal Rights Amendment. Most of all, they are united in their opposition to the Reagan administration.

"There is clearly room in the Congress for another Mike Barnes," said Michael D. Barnes, who agreed to make the campaign appearance to help Michael P. Barnes unseat conservative two-term Republican Rep. John Hiler.

Unlike the two men, the constituencies of Barnes and Barnes appear to have little in common.

Maryland's Barnes represents one of the most educated and well-to-do congressional districts in the country, which has allowed him to carve a role for himself in Congress as a key player on foreign policy issues. Barnes is chairman of a House Foreign Affairs subcommittee on Western Hemisphere affairs, which handles legislation involving Central America.

The district that Barnes would represent in Indiana if he is elected has an urban center in South Bend, home of the University of Notre Dame, but other than that is largely rural.

"There isn't too much concern about Central America here," said Indiana Barnes' aide. "We haven't made too many statements on it."

Indiana's Barnes learned about Maryland's Barnes a few months ago after his staff began tracking a handful of congressmen to compare their positions on issues. At first Michael P. Barnes was "amused" to find out that he had a namesake already in Congress, but then his staff decided it was a great way to get attention for his campaign.

The effort apparently has paid off. "Barnes to Barnstorm for Barnes" said a recent headline in The Elkhart Truth, a local daily. And 1,000 people have bought tickets to tonight's fund-raiser for Barnes, according to his staff.

What remains to be seen is whether Barnes, who is being flown in at the Barnes' campaign's expense, can really help get Barnes elected. While Maryland's Barnes is considered a shoo-in for reelection to his fourth term, Indiana's Barnes must defy the odds and win in a district that typically votes Republican in presidential election years.

If he wins, confusion is sure to reign on Capitol Hill. Already in the House of Representatives there are 21 shared surnames, including six Smiths, three Joneses, two Longs, four Halls, three Edwards, two Browns, two Millers, two Evanses, two Fords, two Lehmans, two Burtons, two Colemans, two Cranes, two Lewises, two Andrewses, two Youngs, three Martins, two Williamses, two Hansens, two Morrisons and two Thomases.

But two Michael Barneses would be a first.