Egypt and Sudan have pledged substantial military assistance, including troops, to help defend Somalia if Ethiopia invades the Indian Ocean nation, two U.S. congressmen said yesterday.

Reps. Don Bonker (D-Wash.) and Paul Tsongas (D-Mass.). who met with Egyptian President Anwar Sadat last month during a five-nation tour of northeastern Africa informed President Carter yesterday that the Egyptian leader said he had already sent $30 million in arms aid to Somalia and promised an armored brigade in the vent of an invasion. Sadat said Sudan has made a similar pledge of a brigade, making the total commitment for the two countries 4,000 to 5,000 troops.

Bonker and Tsongas urged Carter to adopt a more even-handed policy toward the Ethiopian-Somali conflict and cautioned against regarding the escalating crises in the horn of Africa solely in terms of the rivalry between the Soviet Union and the United

Referring to the massive buildup of Soviet arms in Ethiopia, the two congressmen said in their report to Carter that "recent experiences of Egypt, Sudan and Somalia suggests that in the end African nationalism is a more powerful political force than communism in the African continent."

Bonker and Tsongas, both members of the House International Relations Committee, warned against pushing Ethiopia into the position of having no place to turn except the Soviet Union, as they said Washington did to Cuba in the early 1960s.To prevent this, they urged a strengthening of U.S. ambassador to fill a post that has been vacant for 17 months.

The Congressmen's tour and their meeting yesterday with Carter underlined growing American concern over the expanding Soviet and Cuban involvement in the region. The two congressmen had a rare meeting with Ethiopia's little-known military leader, Lt. Col. Mengistu Haile Mariam, who told them that Ethiopia intended to remain nonaligned despite its turn toward the Soviet Union for military assistance.

In urging a more even-handed policy, they said the United States should condemn the Somali incursion into Ethiopia's Ogaden region but also express concern over a possible Ethiopian invasion of Somali.

"Should the Ethiopians cross the border into northern Somalia, there will be regional warfare involving the Somalis, Egyptians , Sudanese and perhaps other Arab League states," they said.

In their report on their visit to Egypt, Sudan, Ethiopia, Somalia and Kenya in mid-December, Bonker and Tsongas referred to a complaint made to them by Egypt's President Sadat at the "void" in U.S. policy in the Horn of Africa. They cited a remark by Sadat that he was being obliged to act "like a superpower" in the area because of U.S. inaction.

Sadat reportedly told the two congressmen that he has already supplied more than $30 million in arms to Somalia but had rejected an invitation to occupy the port of Berbera, from which the Somalias ousted Soviet forces in November because of their arms aid to Ethiopia. The arms Egypt has povided are understood to be mostly obsolete Soviet weapons in the Egyptian arsenal.

The two congressmen reported that Sadat was in agreement on the need for a regional alliance of Ethiopia's neighbors to counter the growing Soviet influence in that country. Sadat told them that Egypt and Sudan, backed by Saudi financial assistance, were committed to provide a brigade of troops each to Somalia if Ethiopia invades.

In their recommendations to Carter, Bonker and Tsongas advocated that the United States make clear its position of "total neutrality" between the warring states, increase economic and humanitarian aid to all parties, voice "deep concern" for human rights in Ethiopia and denounce Soviet activities in the Horn of Africa.