Defense Secretary Caspar W. Weinberger warned yesterday that if Congress freezes defense spending, President Reagan's military buildup will be crippled, the U.S. position in forthcoming arms talks with the Soviet Union weakened and the Pentagon forced to scrap plans for thousands of critically needed weapons.

In testimony before the House Budget Committee, Weinberger said spending targets that the Senate Budget Committee passed Tuesday would mean elimination of 5,000 missiles, 175 airplanes, 240 M1 tanks and two ships.

But Weinberger, making his first appearance on Capitol Hill since the Senate action, ran into skepticism from Democrats on the House committee, who suggested that the administration faces the same rebellion in both chambers of Congress.

"This country's got a problem," said Rep. Pat Williams (D-Mont.). "Neither our missiles nor our secretary of defense shoots straight."

Weinberger, calling the spending-freeze move "very unfortunate," said, "we should not even consider" the Senate committee's decision to allow next year's defense budget to grow only enough to keep pace with inflation. If passed by Congress, it would slash Reagan's proposed military outlays of nearly $1 trillion over the next three years by $79.3 billion, starting with $11 billion in fiscal 1986.

In what appeared to be a coordinated administration counterattack, Navy Secretary John F. Lehman Jr. told a Senate subcommittee that the cuts would require the closing of naval installations and cancellation of the Navy's aircraft program and three-quarters of its shipbuilding program.

"In reality, any distortion of the [weapons] program, fully anything to the sacrifice of other elements, leads you to the same problem -- inability to fight," said Lehman.

Weinberger, defending the administration's $313 billion defense budget bill, said the only programs that would remain untouched if Congress froze spending are the strategic modernization program, the "Star Wars" space defense project and pay for servicemen.

But committee Democrats accused him of trying to trick the American people with such dire forecasts.

Williams, noted that past threats to eliminate weapons programs never came true. "What did you do?" asked the Montana congressman. "None of it."

Weinberger denied making such forecasts, saying that if he had, he had been referring to deeper cuts in past Pentagon requests than had come to pass.

Then, the defense secretary accused Williams of making "ridiculous" comparisons of military and civilian government-pay scales and said it is the willingness of servicemen "to be shot at and killed" that "allows us to stay here and have our little free speech."

"There are those of us who are friends of defense and we respectfully differ [with you] and believe you can freeze" defense spending, said Rep. Martin Frost (D-Tex.).

Lehman, in his appearance before the Senate Appropriations defense subcommittee, was pressed by Sen. Arlen Specter (R-Pa.) to explain why the administration put out a "hit list" of 22 possible base closings as Congress was considering moves to curb defense spending.

Lehman assured the committee that the administration was not proposing the closings. Instead, he said, the Pentagon produced the list after Sen. Barry Goldwater (R-Ariz.) asked Weinberger to describe the impact of a defense-spending freeze.

"If such a radical move as a freeze was actually approved," said Lehman, "I would expect that list to grow."

Sen. Ernest F. Hollings (D-S.C.), who sponsored the Budget Committee spending-freeze plan, called the base-closing threats "terroristic activities" and pointed out that his measure allows outlays to keep pace with inflation and does not cut programs.

Lehman, strongly defending the administration's shipbuilding program, said new vessels were necessary if the United States is to meet its far-flung defense obligations.

"We cannot continue to pretend and lie to the American people that we can meet our 40 some treaty commitments," said Lehman, "that we can keep our economy afloat, that we can keep 90 percent of the strategic minerals coming by sea from every continent and to keep the oil flowing with a fleet that is reduced in readiness, size and manning that would be mandated by this" defense-spending freeze.

"I cannot overstate the violence to our programs if what the Budget Committee has done were ever carried through," he added.