Russia suffered outnumbered invasions over its western border throughout history. These invasions include Napoleon in 1812, Nazi Germany -WWII, Germany and the Austro-Hungarian Empire during the WWI, England in 1854, Poland in 1609, and more.
Each of these invasions was destroying and ravaging. Russia always lost more soldiers than the raiding armies did. Retreating slowly from the enemy was the battle’s strategy.
After the second world war, about 25 million soldiers died. The Soviets then wanted to stop more invasions,thus, kept territories along their western border they have invaded and conquered. They consider it as the “buffer zone” between them and the west.