First, when the Han Dynasty fought against the Xiongnu, its national strength was not strong enough to defeat the Xiongnu.
When the Han Dynasty fought against the Huns, it had just experienced the battle between Chu and Han. At that time, the country was relatively depressed, the national strength was not strong enough, and the logistics support could not keep up with the successive wars of the army at that time. It was already very tired. In the face of such a powerful enemy of the Huns, Emperor Gaozu could not defeat the Huns at that time, so he had to make peace and finally agreed to the terms of the Huns before releasing him, otherwise the Han Dynasty would be in danger of collapse. From then on, Emperor Wu of the Han Dynasty could only ease the relationship with each other by kissing, and it didn't improve until the later period of Emperor Wu of the Han Dynasty.
Second, the Qin Dynasty was powerful, so it was easy for Qin Jun to defeat the Huns.
Qin was able to defeat Xiongnu at that time because Qin unified the six countries and was able to gather all its strength to defeat Xiongnu. And at that time, Qin Jun was very strong, and it would not lose to the Huns if it could sweep the six countries. With strong fighting capacity and favorable security, Xiongnu and Qin Jun could not win the war at all. At that time, Qin Jun went 700 miles into the Huns' land, which made the Huns dare not release their horses to the south.
Third, Qin Jun had excellent generals to lead troops, while the Han army did not have excellent generals at that time.
At that time, the general who led the troops in Qin Jun was General Meng Tian. He is very capable of leading troops and often fights with Xiongnu at the front. He knows the Huns better and naturally gets twice the result with half the effort. At that time, almost all the people who could fight in the Han Dynasty were killed by Liu Bang. Liu bang was afraid that they would threaten his rule and killed them one by one. There is no general who can fight, so the Han army can't beat the Huns.