Attorney General Griffin B. Bell asked a federal judge yesterday to dismiss as a "political question" a suit brought by 25 past and present members of Congress challenging President Carter's decision to cancel a mutual defense treaty with Taiwan.

Making a brief and rare court appearance, his third since becoming attorney general in 1977, Bell said the issues posed by the suit involve questions with which courts have been reluctant to become involved.

But if U.S. District Court Judge Oliver Gasch decides to rule on the merits of the suit, Bell said, the government's position is that the president has full authority under the Constitution to cancel a treaty without consulting the Senate or Congress first.

Bell, who spoke only briefly before turning the argument against the suit over to Justice Department attorney David Anderson, said he was appearing because the matter "is important to the president" and because Sen. Barry M. Goldwater (R-Ariz.), one of the lawmakers who filed the suit, was in court.

When Carter announced in December that the United States was reconizing the People's Republic of China as the sole legitimate government of China, he also announced that the United States was invoking a clause of a 1954 mutual defense treaty between the United States and Taiwan allowing either country to cancel the treaty on one year's on one year's notice.

Goldwater's suit maintains that the president either must seek the advice and consent of the Senate by a two-thirds vote or approval of a majority of both houses of Congress. The suit argues that the defense treaty's language allowing either "party" to cancel it means that those who participated in making the treaty also must participate in dissolving it.

Anderson, in arguing for dismissal of the suit, said that Carter's action in canceling the defense treaty with Taiwan constituted a fundamental change in foreign policy and involved an exercise of presidential war powers. He said that court intervention could keep the defense treaty in effect beyond the expiration date.

The Senate, Anderson contended, has already given tacit approval to Carter's action by passing legislation to facilitate recognition of the People's Republic.

Anderson said he was not arguing "that recognition power allows the president to do anything," but he said that "the president simply did what he had the perfect right to do and that is recognize the PRC as the sole government of China."

The court, Anderson said, "should not get involved where the risks of upsetting delicate international relations are so great."

Both Bell and Anderson told Gasch that the Senate's role in foreign policy is limited to giving advice and consent. "Treaties," Anderson said, "aren't made like laws and they needn't be terminated like laws."

Paul Kamenar, attorney for Goldwater and the other lawmakers, told Gasch that termination of the treaty involved a "shared power" of the Senate and the president. Kamenar said that of 55 treaties terminated by the United States, 52 were broken with congressional approval and the other three provided no precedent for the action Carter has taken with the Taiwan treaty.

Kamenar said the matter is appropriate for the courts to review because it is not a political question but a "simple constitutional issue of procedure" involving who can terminate a treaty.

Goldwater has pending before the Senate a sense-of-the-Congress resolution that expresses the contentions of his suit. Another resolution, sponsored by Sen. Harry F. Byrd Jr. (Ind. Va.), expresses the sense of Congress that Senate approval must be given before a treaty can be terminated. Senate action on the resolutions is expected within the week. Neither would have the force of law if enacted.