Flashing a television picture of the stars and stripes and playing "America, the Beautiful" in the background, astronauts Thomas K. (Ken) Mattingly and Henry W. Hartsfield prepared today to become the first Americans to return from space on the Fourth of July.

"This is the best spacecraft that ever has flown, and we appreciate the work of the American people who have made all this possible," Mattingly said as the space shuttle Columbia flew over the Gulf of Mexico on its 96th orbit. "We wish there was some way we could have all of you come up and join us to appreciate how beautiful this is."

Mattingly and Hartsfield plan to land the 100-ton spacecraft at 12:10 p.m. EDT Sunday on the concrete runway at Edwards Air Force Base in California's Mojave Desert, ending seven days in space on the fourth and final test flight of Columbia.

In the desert to greet them will be a predicted throng of more than half a million and President Reagan, who was expected to welcome the astronauts home with a July 4th speech emphasizing U.S. strength in space.

What Reagan will say about U.S. goals in space is not known, but some observers expect him to commit the country to a permanent space base in Earth orbit that could be operating between 1988 and 1990, hold from 12 to 24 people and cost between $4 billion and $6 billion.

Such a space station would circle at an altitude of 300 miles, no farther north than North Africa and the southern United States but as far south as Argentina and South Africa. It would serve as a launch platform for satellites and spacecraft and as an Earth observation post with civilian and military uses.

"It's not a matter anymore of whether we build a space station, it's only a matter of when," Johnson Space Center Director Christopher Columbus Kraft Jr. said in an interview. "We are now in a position in this country to take advantage of space because of the success of the space shuttle."

The astronauts are returning from a mission that has been so successful they have not had to deal with even the small failures that nagged the first three test flights.

"This has been the cleanest flight we've had to date," Flight Director Harold Draughon said at the Johnson Space Center. "I had planned to bring the team in a couple of hours early on entry day to make sure everybody was tagged up on things that were abnormal, and the last thing I did today was tell the team that they didn't need to come in early."

Though there was no way to confirm it, the only thing believed to have gone wrong was in the workings of the Air Force's 2,000-pound instrument package in Columbia's cargo bay. Mattingly has dropped several hints of trouble with the instruments. He did it again late today when he was chatting with astronaut Michael Coats in the Mission Control Center.

"I know you had some disappointments," Mattingly said, "but I hope you had some successes, too."

The astronauts' last day in space will wind down at 11:10 a.m. EDT Sunday, when they point the nose backwards and the tail to the front, then fire their maneuvering engines to slow down as they move northeast off the western coast of Australia.

Over Guam, the shuttle will descend and reach the Earth's uppermost atmosphere, west of the Hawaiian Islands, at almost 25 times the speed of sound.

Penetrating the atmosphere at 21.5 times the speed of sound, Mattingly will move Columbia's nose up, then bounce it down and up again to see how the onboard computers correct for the sudden changes.

At 13 times the speed of sound, Mattingly will perform a sharper maneuver called the "Alpha Sweep," a roller-coaster motion that will take Columbia's nose up 45 degrees, then down 45 degrees and then up again. He will do the same maneuver again at 8.4 times the speed of sound just before Columbia crosses the California coast north of Santa Barbara.

Mattingly will land Columbia on the concrete runway at Edwards Air Force Base. Up to now, the space shuttle has been brought home on one of the dried-out lakebeds at Edwards or the gypsum desert runway at the White Sands Missile Range in New Mexico.

The concrete runway at Edwards is 300 feet wide and 15,000 feet long--much narrower and shorter than the lakebed runways. Later shuttle crews will make such landings routinely on a concrete Kennedy Space Center runway that has the same dimensions.

"There are only two things you can do wrong: one is run off the side and the other run off the end," Flight Director Draughon said today. "We don't plan to do either one of those."