The chairmen of the House and Senate Budget committees yesterday sharply attacked President Carter and Congress for knuckling under to farm pressures and boosting agricultural subsidies far more than needed.

Rep. Robert N. Giaimo (D-Conn.), chairman of the House Budget Committee which yesterday completed final work on a 1978 budget with a deficit of $58.4 billion, said Carter's credibility is at stake.

Giaimo charged that an "administration committed to a balanced busdget in 1981 cannot continue to talk restraint, yet fail to carry out that commitment during the legislative process. There is a very serious prospect that the administration's credibility will be severely weakened in this area."

Senate Budget Committee Chairman Edmund S. Muskie (D-Maine), who has clashed over budget issues with the President before, said the administration appears to have "given in and now accepts spending as much as $2 billion above the level recommended in the budget update just three weeks ago."

"One wonders what further surprises from the President are in store for those of us who believe that this administration is trying to reduce spending." Muskie said in a statement.

In May the Senate passed a farm bill that increased supports for wheat prices and set agricultural spending at $5.5 billion - $1.2 billion higher than the 1978 congressional budget target of $4.35 billion. President Carter proposed spending $2.3 billion on agriculture when he announced his 1978 budget in February.

The House is at work on a bill now that has added about $400 million in additonal corn price supports and $200 million to $300 million to subsidize sugar producers under a program proposed by the administration

Giamo said the "House has gone too far in addressing its legitimate concern for the crisis in agriculture." He said the price supports ae exorbitant and will assure more overproduction and higher costs to consumers.

Giaimo charged that while farmers get billions of dollars from Congress, New York City on the verge of bankruptcy two years ago "was given a direct loan - not an outright grant - and was required to repay the loan promptly, in addition to cutting services in order to balance its budget."Giaimo said urban legislators band with farm state members in return for support for food stamp programs and a higher minimum wage.

"They're paying too high a price,"Giaimo said, pledging to urge Carter to veto the farm legislation.

Despite the increase in farm spending, the House Budget Committee yesterday approved a binding 1978 budget with spending $2.5 billion lower than in the tentative budget adopted last spring.

Because the economy is expected to be stronger than experts thought last May, the House committee members think tax receipts in fiscal 1978 will be $3.3 billion higher than projected last spring.

As a result, the deficit will be $58.4 billion, compared with the estimate of $64.65 billion. Early this month the President projected a deficit of $61.5 billion for fiscal 1978, which starts Oct. 1. The deficit is expected to be $52.6 billion during the current spending year.