I like to think that for the first 16 years we were just stupid. A stupid hangover from Afghanistan — on hindsight it would have been better to let the Soviets crush the Mujahideen and then advance on Pakistan.
Even that whole charade was completely misrepresented to sell it to the American public. There was no Soviet “invasion” of Afghanistan any more than there was an American invasion of South Vietnam; the Afghan GOVERNMENT asked the Soviets for help (as Saigon did with us years before), and the government they were supporting lasted for years after the USSR collapsed (I believe it fell in 1996 - it lasted longer than South Vietnam did after our withdrawal).
Like Americans today, the Soviet troops worked in collaboration with the official Afghan army (though they were allowed to shoot back).