It seems that the combined weight of all of China should’ve been able to steamroll the Korean kingdom, but they managed to smash any army and resist any invasion attempt that Sui threw at them. How did they manage this feat?
While there is a common heroic version of the Goguryeo victory, with a million-man invasion by the Sui, and the nearly-complete annihilation of a force of 300,000 (over 99% killed) attempting to take Pyongyang (the capital of Goguryeo) by a defending force of 10,000, the reality appears to have been rather more ordinary.
The above "great victory" is the semi-legendary Battle of Salsu. We know very little about the actual battle, and don't have reliable data for the numbers of either side. The conventional 300,000 comes from the size of the Sui force that crossed the Yalu into what is now modern Korea (much of Goguryeo was in what is now Manchuria, and a large part of the Sui army appears to have stayed north of the Yalu). The across-the-Yalu force appears to have run out of supplies, but continued anyway (presumably living off the land to the extent possible). They fought and won some battles with Goguryeo, and got very close to Pyongyang. At this point, Goguryeo submitted - they surrendered. The Sui commander didn't trust Goguryeo, but being without food, they were not in a position to undertake a siege, nor even in a position to stay there and wait. Facing starvation, the Sui commander accepted the submission, and withdrew. As they were crossing the Salsu River, they were attacked by Goguryeo, and scattered, and continued their retreat. Supposedly, a mere 2,700 survived to cross the Yalu on their return journey. The great heroic narrative has Goguryeo breaching dams they had built across the Salsu upstream, drowning many thousands of Sui soldiers. Perhaps they did make use of hydraulic warfare like this - flood as a weapon of war was already an ancient Chinese tradition by that time (and continued to be used as recently as the 2nd Sino-Japanese War). However, it is quite possible that far more Sui soldiers died of starvation than drowning - they were retreating back along their own line of advance, where they would have collected all available food on their way south. We don't know how much of the Sui defeat was due to the cunning and heroism of Eulji Mundeok, the Goguryeo commander, and how much was due to failure of Sui logistics. But logistical failure must take a large part of the blame.
Thus, the second Sui invasion of Goguryeo failed. The first invasion, 14 years earlier, appears to have due to weather and failure of logistics. Heavy rain hampered supply, and the naval force lost many ships to rough seas. As would happen in the second invasion, the army attacking by land was short of food already when they crossed the Yalu. Lack of supplies, and mounting losses due to illness (and also resistance by Goguryeo) resulted in the abandonment of the invasion.
A third invasion was attempted the following year. This entered Goguryeo territory, but stayed north of the Yalu. Before much could be achieved, a major revolt and coup attempt demanded the immediate return of the army - what point in fighting Goguryeo if China is lost?
The fourth invasion, the next year, was more successful. Goguryeo promptly submitted. The Sui army, quite likely struggling with supply judging by their previous invasions, accepted the submission and withdrew. The king of Goguryeo failed to come to Luoyang to offer his submission in person, so a fifth invasion was planned. However, the Sui state disintegrated.
The conventional heroic story presents the loss at Salsu as crippling to the Sui. However, they were still strong enough to invade in the two following years, 613 and 614, and the response to the 4th invasion in 614 was prompt surrender by Goguryeo. Sui does not appear to have been too weak. However, the do appear to have struggled with logistics. In comparison, the Ming sent a much smaller force to support Korea when Hideyoshi invaded in 1592, with under 50,00 troops on land. The Koreans asked for more, but the Ming could not support a larger force. Logistics matter, and the Ming appear to have paid much more attention to logistics than the Sui.
One complication is that these invasions of Goguryeo came at the end of the Sui Dynasty, and the last emperor or few of a dynasty are invariably harshly treated in the dynastic history. These histories are written by the following dynasty, and as well as recording the history of the previous dynasty, they seek to legitimise the rule of the new dynasty by portraying the last emperor(s) as having lost the Mandate of Heaven due to their corruption, incompetence, and evil. There might have been an element of exaggeration for political purposes in the sources describing these wars.
While there may have been a great victory at Salsu, the 3rd and 4th invasions show that it was not enough to save Goguryeo. Instead, Sui failure came from poor logistics, delaying tactics by Goguryeo (such as the feigned submissions), and the disintegration of Sui before they could finish the job.
For some past discussion of the Battle of Salsu by u/Abyssight see https://www.reddit.com/r/AskHistorians/comments/3rcvgl/i_was_reading_about_the_battle_of_salsu_where_in/
See also the comment by u/daqafwz on the reliability of the sources for the great victory at Salsu in https://www.reddit.com/r/todayilearned/comments/1dewll/til_that_the_korean_goguryeo_army_of_about_10_000/