Secretary of State Alexander M. Haig Jr. returned to Washington last night after meetings with leading officials in Mexico City during which Mexico is understood to have demonstrated a willingness to take private diplomatic action to express its concern to Nicaragua about that country's military buildup and limits on political freedoms.

Such diplomatic expressions of concern coming from Mexico, a country that has lent political and economic support to the leftist Sandinista government of Nicaragua, would carry greater weight than continued public warnings by the United States, it is believed.

Haig met yesterday with Mexican President Jose Lopez Portillo and also held several hours of talks with Mexican Foreign Minister Jorge Castaneda during his 24-hour visit to Mexico.

U.S. sources acknowledged that the Mexican government remains nervous and concerned about a host of developments, including the continuing stream of statements from Washington that leave the door open to some kind of U.S. or joint military action against Nicaragua. The Mexicans also are said to be upset about the growing turmoil in Central America.

The Mexicans play a vastly different role in Central America, and they can bridge differences between rich and poor nations more easily than the United States. Washington is said to be comfortable with that role for Mexico.

Whatever Mexico does with regard to the situation in Nicaragua is extremely sensitive because Mexico's potential influence there could be lost if Mexico is perceived as an arm of the Reagan administration.

The United States reportedly did not make any suggestions to the Mexicans about how to handle future complaints and contacts with the Sandinistas.