IMHO the simple answer is to have civilization rise and flourish and develop for centuries and millennia. Then the outside threat arises from somewhere outside.
Maybe a fleet of spaceships lands and invades. Maybe an astronaut returns infected by alien organisms, turns into a mother monster, and spawns hordes of monsters.
Maybe a new and improved sailing ship design allows the discovery of other continents. In which case perhaps the explorers capture a few baby monsters and bring them home and the baby monsters grow up, escape, and reproduce, infesting the continent with monsters.
Maybe the explorers find a "lost world" and bring back a few dinosaur eggs that hatch.
Or maybe there are civilizations on both continents and the explorers form colonies on the new continent and expand, conquering some of the natives, and other native societies build walls to keep the newcomers out.
And it is possible that more than one species of intelligent beings might exist on your planet.
Most humans assume that Homo sapiens is the only species of people or intelligent beings on Earth, and has been for many thousands of years since other hominid species became extinct.
But among mammals alone, there are about 90 other species of primates, proboscideans, and cetaceans with very large brains that might potentially be intelligent enough to be classified as people, and thus it is possible that the number of intelligent species currently on Earth might be higher than one and possibly as high as ninety.
The possibility that proboscideans might possibly be as intelligent as humans is especially interesting because proboscideans are land animals and much more widespread than apes, despite their range shaving shrunk drastically in recent centuries. And up until the end of the last glacial period 13,000 years ago, proboscideans lived on every continent settled by humans except Australia. In addition to the three surviving proboscidean species there were at least 15 more species 13,000 years ago that have become extinct since then, with human hunting being blamed by many as a contributing factor.
Since humans are also blamed by some for causing or contributing to the extinction of other hominid species, the possibility of violent conflicts between various groups belonging to different species of intelligent beings on the same planet seems fairly plausible. If some of those groups are civilized, building walls might be one thing that they do because of those conflicts.
And even within a single species, different countries, tribes, and groups can fight wars, such as happened many times on Earth. Thus civilizations in both the Old World and the New World often built defensive walls.
And perhaps the history of Eurasia might be instructive. There were many defensive walls built around towns and cities, and sometimes around larger areas. And then, Genghis Khan united the Mongol tribes and set out to conquer the world, and the Mongols conquered the largest contiguous land empire in history, and massacred many millions of people in the process.
It may be noted that Egypt under the Mamluk sultans managed to defeat and hold off the Mongols in Syria. But if the Egyptians had been less successful they might have abandoned Syria and built a short defensive wall in the narrowest part of the Sinai peninsula. That would have made the entire African continent defended from the Mongols by a wall in the Sinai.
The Song Dynasty of China never ruled the northernmost parts of China and so probably never defended or maintained the Great Wall. But they did construct a forested belt to defend against the Liao dynasty of the horse riding Khitan, who in turn built long sections of northern walls. During the Song-Jurchen alliance against the Liao of 1115-1125, the Song removed the defensive forest, and then the Jin Dynasty of the Jurchen attacked and conquered northern China in 1127.
The Jurchen saw no need to recreate the forest barrier in the middle of their land, But they did build two long stretches of the Great Wall of China as a defense against the Mongols. When the Mongols conquered the Jin Dynasty of northern China from 1211-1234 they preferred to go around walls and fortifications whenever possible, or persuade the disaffected Khitan garrisons to let them pass through.
If the Liao and Jin dynasties had maintained, rebuilt, and added to the Great Walls enough to make them impregnable and impossible to go around, and if the Jin had kept loyal garrisons on the walls, they might have kept the Mongols out of China and saved tens of millions of lives.
Even though the Mongols had the typical nomadic dislike for sedentary peoples, and even though they massacred tens of millions of people, they didn't try to exterminate all civilized and sedentary people.
In a fictional setting there could be an even more terrifying version of the Mongols, combining the worst features of Nazis and Mongols, that do exterminate every single civilized person they can catch. In such a setting, civilization can only exist where those ultra Mongols cannot reach, and perhaps the only way to hold those ultra Mongols off is to build walls they cannot penetrate. Thus the only civilizations in that world would exist behind defensive walls.
It may be noted that civilized societies build many walls for reasons unrelated to military defense.
There is the Inland Customs Line in British India, for example.
https://en.wikipedia.org/wiki/Inland_Customs_Line1
Or the Dingo Fence of Australia:
https://en.wikipedia.org/wiki/Dingo_Fence2
So possibly the civilization had its walled cities and its farms and pastures all surrounded by a great wall, and outside there are ravenous predators that would eat all the flocks if they got inside the wall, and/or vast herds of large herbivores that would eat up all the crops and the pastures if they could get inside the wall.
And possibly if the vast buffalo-like herds of herbivores got inside the great wall and stampeded when the people tried to chase them out they would knock down houses and barns and orchids and make a terrible mess of things.
Or possibly there are terrible weeds outside the wall that only spread though their roots, that would choke out the food plants if they got inside the walls.
So possibly the civilized people would be in danger of starving to death without their food sources without their great wall, but would not be in danger of being massacred by human enemies combining the worst features of the Nazis and the Mongols or being eaten by man-eating monsters. There are many different kinds of danger.