Two weeks after they invaded Vietnam, the Chinese may be learning what others have found before: Once you enter a fight with the Vietnamese it is very difficult to find a way out.

While senior Chinese officials are continuing to predict and end to the Chinese invasion in the near future, Western analysts here as well as Hong Kong sources with links to Peking are now beginning to suggest that the two sides may find it impossible to stop the fighting completely.

A Chinese decision to withdraw to its own borders, some analysts say, may tempt the Vietnamese to attack the retreating troops and claim victory. In turn, this would inevitably bring further Chinese retaliation.

With nearly 100,000 Chinese Troops over the border, some of them as deep as 20 to 25 miles into Vietnam, "an orderly withdrawal is notoriously difficult," a Western military analyst said. "It is a decidely embarrassing and messy operation."

An American analyst, referring to Washington's efforts to end the Vietnam war, said: "At one time we thought we could end the war quickly. The Chinese may learn that once you enter [Vietnam] it's very hard to find a way out."

A Hong Kong source with close ties to Peking was asked what China would do after withdrawing if the Vietnamese resumed harassment raids across the border, something many analysts consider inevitable.

"Once we've given Vietnam this lesson," he said, "it is much easier for us to give them another lesson."

Echoing Chinese Vice Premier Teng Hsiao-ping's warning of more invasions to punich any further Vietnamese "provocations," the source said he thouth many obstacles to future Chinese attacks had been cleared away.

"Over the last two years the Vietnamese put up all kinds of obstacles, the sharpened bamboo sticks, the mines, the camouflaged machine guns... That has now all been smahed by our troops," he said.

A Western analyst disagreed.

"The Vietnamese can put all those things back up in 48 hours," he said. Some European diplomatic sources said the Vietnamese are producing more fortification materials now, and are even sharpening steel reinforcing rods, acquired for building constrtuction under a Swedish aid program, for use in booby traps.

Analysts say that having risked one major invasion, the Chinese may be more willing to launch smaller raids across the border in the future. But Vietnamese guerrilla tactics, making full use of the hilly, cavern-ridden terrain of the border area, would hamper future Chinese actions as much as they appear to have hampered the current one.

Vietnam's invasion of Cambodia and China's invasion of Vietnam have many ironic connections, beginning with the fact that the first invasion had much to do with causing the second.

The Soviet Union has appeared as reluctant to help its Vietnamese allies in Vietnam as the Chinese were reluctant to aid its Cambodian allies in Cambodia. They restricted their assistance to weapons and advisers for several weeks until they finally launched the Feb. 17 attack on Vietnam.

But most importantly, both sides have found that suppressing a mobile, determined enemy on his home ground bogs down thousands of troops and makes any withdrawal seem a retreat.

Vietnam now has an estimated 100,000 troops in Cambodia. The pro-Hanoi government in Phnom Penh seems far from gaining sufficient political control so that those troops can withdraw.

Many Chinese statements recalling their month-long invasion of India in 1962 suggest Peking planners hoped the Vietnamese, like the Indians, would be frightened and cowed by a short, bloody stroke across the border.

With a sign of relief, the Indians let the invaders return to their border. There was no vicios counter-attack.

An American journalist who visited the front and talked to Vietnamese troops last week thinks such a meek response from them is unlikely.

"The Vietnamese seem to live for war," he said.

An analyst here said he was less certain Hanoi would try to attack the retreating Chinese forces and make it look like a rout.

"If they shoot the Chinses up, they may not leave so quickly," he said.

"It's conceivable to me that when the Chinese decide to go home, the Vietnamese might give them problems by trying to make them look bad. On the other hand, they might be harry to see them go quickly.

"In any case, I think when the Chinese decide to go, they'll go whether it exposes them to attacks from the rear or not. They're pretty callous about casualties."

Future Vietnamese border attacks would become even more likely if the Chinses, as they have hinted recently, post troops after their "withdrawal" on disputed parts of the border that were in Vietnamese hands before the Feb. 17 invasion.

Western analysts say they know of no serious dispute between the two sides over the location of the border. They suggest the Chinese are creating a new issue as a bargaining tactic to force a more conciliatory attitude from Hanoi on such matters as its influence over Cambodia.

The Chinese Ministry of Foreign Affairs note yesterday suggesting negotiations with Vietnam referred to "disputes between the two countries concerning the boundary and territory. A Feb. 26 offical Chinese news report referred to a Chinese army unit "recovering the Tinghao Mountain area of Chingsi county in the Kwangsi Chuang Autonomous Region," indicating a piece of Vietnamese territory apparently claimed by China.

Hanoi today again rejected offers to negotiate, demanding Chinese troops vacate Vietnamese territory.

Some Western analysts suggest there is no real border dispute to settle. Vietnam's alliance with the Soviet Union, and its invasion of Cambodia, are what bothers Peking. In their view, the border dispute is an excuse to keep pressure on Hanoi to alter its foreign policy.

Seemingly the only practical way to ensure peace on the border, short of imporved relations between Peking and Moscow or a Hanoi-Moscow split, would be complete evaluation of the area by both sides. But the Chinese have publicy indicated that they attacked Vietnam to allow Chinses villagers to move back to areas once threatened by the Vietnamese.

"Old folks like me had to go and live in caves," one elderly Chinese woman, happy to return to her border home, was quoted as saying by Peking's New China News Agency. "Tell our soldiers to give hard blows at the Vietnamese invaders."