Twenty-two of the top 25 federal contractors have agreed to adhere voluntarily to White House wage and price guidelines, Budget Director James McIntyre said yesterday as he announced the first contract with such limits.

Under the $1.9 billion National Aeronautics and Space Administration contract, Rockwell International -- which does one-third of its business with the federal government -- will build and modify four space shuttle project vehicles.

Under the agreement, Rockwell must certify it is in compliance with the guidelines.

Donald Beall, an executive vice president for the firm, said "as a practical matter, you might conclude" Rockwell had no choice in the matter because the White House has said it will withhold contracts from those who refuse to comply with the guidelines.

Separately, however, General Accounting officials said yesterday President Carter will be breaking the law if he denies contracts to companies that do not comply with the guidelines. They call for holding all wage increases to 7 percent a year or less, and price increases to half a percentage point below their 1976 and 1977 average.

Milton Socolar, GAO's general counsel, told a House subcommittee that Carter's actions "lack the force and effect of law." He said the president needs approval from Congress before he can enlist the government's contracting process in his anti-inflation battle.