Might want to read some history books about this; many civilizations got their roots from banding together because of raiders, and it's been a constant problem for such kingdoms since man started farming. China had its wall built as a road block for steppe nomads while the main army mobilized to fight back. Alfred the Great built castles and forts around Saxon England to prepare for inevitable Viking raids. The Crusader Kingdoms and their Muslim counterparts all had good sized standing armies that could react quickly and decisively to attack incursions launched by their opponents during times of war. A society that had to deal with yearly raids would have a decently sized, well funded standing army around its major centers, ready to sally forth whenever raiders came along.
Either that or they'd just offer a nice pile of gold and food stuffs to make the raiders go somewhere else. Appeasement has also been around for a long time as well.
All the more reason they would have their own militia force at the very least. If they know that their sovereign state can't be relied upon for basic civil protection they would be far more inclined to rely on their own forces. They perhaps could have their own police/militia/secret police force to deal with matters their own way.
Do you read Sutter Cane?![]()
Fortification. Lots of fortification. Militia will depend on how much autonomy they have. But if they're that wealthy and prosperous, that means that the central authority will want to protect their tax revenue and the local authorities would have a valid arguement for stationing the main army their.
If the central authority consistently cannot or will not protect them... independence movements have been born from less.
Their military is probably also used to escort trade caravans, given how important selling surplus foodstuff is to their economy. Also, what kind of agriculture do they engage in? If they primarily herd animals like cattle or sheep, they might just migrate to a safer location. However, if they develop the land, it would be harder for them to just leave and they'd be forced to defend themselves.
@Shark Toast They do engage in some herding, but mostly they farm the land. Before being incorporated into the Empire, they're government was very simple. Most settlements were governed by village elders or priests.
This is rather late, but that premise is how SW Asia developed in the very early days. See ancient Sumer and Akkad and Assyria for how they adapted. It even works into the Roman and Persian periods as that area was the most frequently raided when those two empires were at odds.
Look with century eyes... With our backs to the arch And the wreck of our kind We will stare straight ahead For the rest of our lives@De Marquis is that a seven samurai reference?
It took until the sequels for Star Wars to have a zero gravity scene.

So this society is based in a valley located at the foot of a mountain range. The valley is extremely fertile, allowing the people there to develop a large agricultural base. They would become wealthy by selling their surplus food. However, this attracted the attention of raiders, who began attacking the valley and looting settlements. These raids would become a regular occurrence, happening yearly. So, what would happen to a society like this? One that grew wealthy and powerful, but is now being attacked and looted every year. How would their culture develop as a result of this?