President Reagan may have wanted to talk taxes when he invited Rep. Steven Gunderson (R-Wis.) to the Oval Office early yesterday, but the young congressman from dairy country wanted to talk cows. So they did.

By the time the session was over, both men had what they wanted: Gunderson knew Reagan would sign the farm bill sought by his rural Wisconsin district; Reagan knew Gunderson would help try to rescue sweeping tax-overhaul legislation in the House.

"I told him my farmers needed a chance in agriculture, and so I think it was only right to give the president a chance on tax reform," said Gunderson, 34. "I think that's a sensible way for adults to do business."

And that's the way business was done, up and down the Republican and Democratic aisles of the House yesterday as Reagan and House Democratic leaders picked up the needed votes to revive a tax bill that many members said they wished would go away.

Only a week ago, in a surprise move, all but 14 House Republicans -- Gunderson among them -- mutinied against the president and blocked consideration of the tax bill. Yesterday, Gunderson and 55 other rebels, including such GOP leaders as Rep. Jack Kemp (R-N.Y.), reversed themselves and supported the president.

Few of the Republican converts said they changed their opinion of the bill. Gunderson, for example, called it "awful." Rep. Henry J. Hyde (R-Ill.) said he "despise s " it. Rep. Guy Vander Jagt (R-Mich.) called it "seriously flawed."

But most said they felt they had won something from the president -- be it a little attention, a promise to veto the bill unless the Senate amends it or, in cases like Gunderson's, a special favor for a House member or his district.

Never mind that Reagan probably would have signed the farm bill anyway or that Gunderson had already decided out of loyalty to Reagan to vote for what he calls a "lousy bill."

Never mind, also, that Democratic and Republican converts appear to have heard contradictory messages in the president's promises. Yesterday each side needed the other, and almost nobody came away feeling empty-handed.

Kemp, a leader of last week's mutiny, voted "yea" yesterday because he said he thinks Reagan would veto the bill unless the Senate changes it. Rep. Wyche Fowler (D-Ga.) said he switched to the "yea" column because he thinks Reagan is bluffing.

"I just don't believe anything I hear about this bill from now on," Fowler said.

Vander Jagt said he voted yea, expecting the Senate to make the bill more Republican. At least two Democrats said they did so because they hope the Senate will kill it.

Some former mutineers came back to the Reagan fold for reasons that might repel the president. Rep. Silvio O. Conte (R-Mass.), for example, said he hopes that the Senate will use the bill as a vehicle to raise taxes and reduce the deficit.

He said Reagan made an unusually emotional appeal to him but that this had nothing to do with his switch.

"He said if this wasn't turned around, he'd be an ineffective president and he couldn't campaign for anyone in 1986," Conte said of his telephone conversation with Reagan last week. "In politics, you always keep the window open. I said: 'Let me think about it,' but I'd already made up my mind."

Conte, sporting a Reagan-signature tie clasp, said his vote did not signal new loyalty to the White House.

"Five years they've been in office. They've given me zilch. I've gotten nothing except this tie clasp," he exclaimed.

But some GOP members said they have gotten something to write home about. Rep. George W. Gekas (R-Pa.) agreed to vote "yea" after Treasury Secretary James A. Baker III promised to study Gekas' proposal to stagger the filing dates for income tax returns.

And in response to a request from Rep. Paul B. Henry (R-Mich.), another former nay-sayer, Reagan promised that his Cabinet Council on Economic Policy would investigate whether import quotas should be imposed on machine tools -- a staple of Henry's district.

Henry said he already had decided to vote "yea" when Reagan made the promise. One of only a few converts to cite the merits of the bill, he said he spent much of the last two weeks telephoning employers in his heavily industrial district, accountants on Wall Street and professors of economics in order to size up the measure.

The Grand Rapids lawmaker said he began as a skeptic, only to find that the biggest companies in his district -- General Motors, several large distributors, manufacturers of office furniture and hardware -- expected to be better off under the bill. So did the spokesmen for workers in the district.

The biggest doubters, he said, were executives of the machine tool and die industry. But thanks to Reagan's promise, Henry said he can tell those executives that they, too, won something -- albeit indirect -- from tax overhaul.

Generally, the Republicans who shifted to the side of tax overhaul came from the Northeast and Midwest, with few converts emerging in areas dependent on timber, oil or mining -- industries likely to pay more taxes under the measure. Rep. Olympia J. Snowe (R-Maine) said the conversion process was "more parochial than partisan."

Vander Jagt said many others converted because they felt that they had won the battle even before the war was over: They had persuaded the president to come to Capitol Hill on Monday and to acknowledge the oft-ignored House Republicans as players in Washington politics.

"That way, people can vote for a bill they may not like and say: We won," Vander Jagt said.

Snowe was one of only a few who reported gaining nothing from the switch. She said she decided to support Reagan largely out of respect for him as the president. She said she hopes the Senate will make the bill more favorable to her timber-dependent state.

"I had some concerns personally that the president found himself in the awkward position of having to come to Capitol Hill and to ask for votes from his own party," she said.

"You wanna know how little I'm getting?" she asked. "I've got a shoe and textiles protection bill [which some view as important to Maine] that he's going to veto today."

As they voted to bring the tax bill to the floor, dozens of members marveled at how few wanted it to pass although many said they embraced the ideal called tax reform.

"It was the sheer aggressiveness of [House Ways and Means Committee Chairman] Dan Rostenkowski [D-Ill.] and Ronald Reagan that dragged Democrats and Republicans kicking and screaming into tax reform," said Rep. Leon E. Panetta (D-Calif.). "Members knew that once they were finally brought to that trough, there was no way they could back away from it."