A green Air Force plane taxied along the landing strip at Andrews Air Force Base just before sunset yesterday and the U.S. Navy Band began to play a slow, solemn version of "Anchors Aweigh."

The body of serviceman Robert Dean Stethem, the 23-year-old Navy steelworker and diver slain Saturday by terrorists aboard a hijacked Trans World Airlines jet, was returned to a somber crowd of dignitaries and family members.

Vice President George Bush, who spoke briefly, called Stethem "an innocent victim of a cruelty that knows no boundaries and a barbarism that selects the blameless for punishment." He said Stethem "was killed by criminals who singled him out for death because he carried with pride among his papers the information that he was a member of the armed services of the United States of America."

At a televised news conference one hour later, President Reagan referred to Stethem as "a young American hero." The president said that Stethem's murder and the fate of the other hostages "underscores an inescapable fact -- the United States is tonight a nation being attacked by international terrorists."

The Pentagon confirmed Monday that Stethem was the passenger who had been beaten and shot in the head by extremist Shiite Moslem gunmen aboard TWA Flight 847, then thrown onto the tarmac at the Beirut airport.

Navy officials said Stethem, a steelworker second class attached to the Navy Underwater Construction Team 1 in Norfolk, had been returning from a routine repair assignment at a Navy installation near Athens. They said early reports that Stethem was a member of the Navy Seals, the specially trained divers who operate as commandos, were erroneous.

Two dozen members of the Navy ceremonial guard, in dress whites, formed an aisle for Stethem's flag-draped coffin as it was removed from the plane, accompanied by Adm. James D. Watkins, chief of naval operations.

Richard and Patricia Stethem of Waldorf, Md., both retired Navy administrators, stood erect, holding hands, as their son's coffin passed; their faces twitched as they fought to control their tears.

Stethem's sister, Sherry Sierratta, was supported as she wept by her husband, Phil, and younger brother, Patrick, 19, who will enter the Navy this fall. Another brother, Kenneth, 24, who is also in the Navy, saluted the coffin as it was lifted into an ivory-colored hearse.

The band played the Navy hymn, "Eternal Father," and members of the Stethem family shook hands with Bush, his wife Barbara and Secretary of State George P. Schultz. They then left, without speaking to reporters.

Earlier in the day, Reagan telephoned the Stethems at their home in Waldorf. He told Patricia Stethem: "All Americans were shocked and deeply saddened by the death of your son. His courage and pride are an inspiring example for us all . . . ."

Stethem is to be buried with full military honors at Arlington National Cemetery tomorrow at 2 p.m.