Latvia has numerous medieval castles.
They date from the era of Baltic Crusades when German knights (Livonian Order) subdued the local pagan Latvians. They later continued their fight by attacking Lithuanians further south. In order to do this they have heavily fortified Latvia.
As the era of crusades ended, the nobility moved from fortified castles to opulent palaces. Latvia has some of the Baltic States prettiest palaces in Rundale and Jelgava which once housed the dukes of Courland and Semigallia.
As Latvia was conquered by the Russian Empire in 18th century it once again was near a borderline of civilizations (Eastern Orthodox and Western). Russians constructed the fortress of Daugavpils and an entire naval military city in Liepāja. Both are well preserved (although partly abandoned) and popular among Latvia’s visitors who see beauty in 19th century military architecture.
However, actual wars in Europe were rare in that era. Before World War 1 (1914), Latvia had spent some 100 years without any warfare on its soil. That allowed local German and Russian nobility to develop large manors centered around extravagant new palaces. These were often built to remind Medieval castles. Some of the prettiest ones stand in Cesvaine, Gulbene area and Western Semigallia. Unfortunately, many of them had their interiors gutted by Soviets who nationalized them, but the restored exteriors give a nice touch to the Latvian landscape. Many of these palaces have been converted into hotels or public buildings.