President Chun Doo Hwan is staging a strategic retreat from the political office that he seized five years ago, looking over his shoulder at the ghosts of his predecessors and at the uncertain U.S. record of dealing with allies who get into trouble.

This impression emerges from a three-hour visit to the Blue House, as the South Korean presidential mansion is known.

Although Chun is far too cautious and too diplomatic to state his plans in such stark terms, his comments clearly reflect these concerns.

Known here for his ability to conceive and carefully follow a long-term plan while keeping it to himself, Chun emphasizes to visitors that his planned retirement in 1988 would mark the first peaceful transfer of power since South Korea became a republic in 1948.

That is, all of his predecessors have been thrown out of office or, in one case, assassinated. If he can get safely to 1988, Chun promises, he will not make the mistake of ignoring the seven-year limit he imposed upon himself in 1981 and hanging on to power too long.

"You must follow the rules," Chun says with the no-nonsense demeanor of a career military officer who specialized in intelligence work. He puffs on a cigarette holder as he speaks with soft but clear authority. As he talks, five aides sit nearby taking down each word.

He has been a leader who not only demands that his countrymen follow his rules but that they not question them. He has closed down newspapers and magazines critical of his government, imprisoned political opponents and sent troops to put down rebellious students through bloodshed.

In his remarks here today, he made it clear that he would not yield an inch to opposition politicians who are demanding that direct elections be held when he steps down to choose his successor.

Instead, he will stay with the constitution he put through in 1981 that many here feel guarantees that Chun will be able to choose his successor, likely to be a close military associate who would continue Chun's policies.

"I have made an oath to protect that constitution," he said as he sat in a gold brocade armchair. "That constitution makes it mandatory for the president to step down after the end of his term. I look forward to fulfilling that obligation."

Chun, who turned 55 last week, won out in the power struggle that followed the assassination of Park Chung Hee in 1979. Park had ruled South Korea for 18 years when he was killed by his own intelligence chief.

Considered colorless and untrained in world politics when he came to power, Chun has emerged in the past two years as an articulate and increasingly confident international figure. Asked about security issues in Asia, he provides a sophisticated analysis of Soviet courtship of North Korea and China's steady distancing of itself from Pyongyang's policies.

But he does not miss an occasion to rattle off the latest order of battle listing North Korean military deployments, or to ask a visitor how long it had taken on the previous day to drive to the Demilitarized Zone, already knowing that the answer was about an hour.

"Yes, this place where we sit is an hour from the DMZ. And it is within North Korean artillery range," he says.

Repeatedly suggesting throughout the conversation that his political opponents here are immature and that the country is not ready for the kind of civil liberties practiced in western democracies, Chun praised Secretary of State George P. Shultz for public statements that Chun said had established "a realistic yardstick" of military, cultural and political factors that had to be considered before making any judgment about democratic freedoms in a given country.

At the same time, there are indications that the Reagan administration consistently has been urging Chun to begin a process of political change by moving forward with a plan to hold indirect elections in 1988 to name his successor.

With 40,000 troops stationed here, the United States is intimately involved with the course of events. Chun gave clear indications today that past U.S. policies and the present U.S. pressure being put on President Ferdinand Marcos of the Philippines to adopt significant reforms cause him concern.

Speaking of outside criticisms of his authoritarian grip on power, Chun warned that "when criticism becomes a direct attack, the result can be very serious. We have seen what happened in Cambodia, Vietnam, Iran and other places." Asked specifically about the Reagan administration's approach to the Philippines, he replied:

"I sincerely hope that the United States would not remove a friendly government without being sure who or what will replace it." He went on to imply that that had happened in the case of the fall of shah Mohammad Reza Pahlavi of Iran, with unfortunate results for the United States.