Both Korea and Vietnam faced powerful neighbors and colonial pressures, but several factors helped Korea preserve its sovereignty more consistently.
Korea's peninsular shape with sea on three sides created a defensible perimeter. Vietnam's long, exposed coastline and land borders invited multi-directional incursions.
Korea's strong centralized military and the genius of Admiral Yi Sun-sin (turtle ships, decisive victories in the 1592–98 Imjin War) prevented Japanese domination. Vietnam's military was often fragmented by internal divisions.
Ming/Qing China intervened decisively in the Imjin War to protect its tributary. Vietnam lacked a consistent, powerful ally during French colonization.
Korea endured 35 years of Japanese occupation (1910–1945) but avoided the century-long French colonial administration that restructured Vietnam's institutions and economy.
Korea's division was a Cold War artifact; Vietnam's unification came after a devastating war. Both regained sovereignty, but Korea's path involved less prolonged foreign administrative control.
These are broad patterns; each nation's history is uniquely complex.