Well Bob, in the hopes that we can keep a historical eye on the facts here instead of allowing this thread to descend into political b******t, the Soviet Union had an eye on Afghanistan since about 1955. That was an extension of attempts to encroach on the region since the days of the Tsars.
Finally, by the 1970's, after years of Soviet funding to various political factions, the Afghan system started to topple. You'll note that socialist/religious factions had been gaining power in the years leading up to various Islamic revolutions. Anyway, it was the Marxist party that seized power and executed scores of people, including the Royal family, Advisors, Teachers and anyone else who had the bad luck of getting out of bed that day.
Then the fun begin...several militant factions tried their hands at overthrowing the government. The majority of these factions belonged to warlords from various provinces. Then radical religious overtones started to fuel the unrest which turned into a full blown rebellion against the Marxist government. Then came the Soviet Union.
The problem that the Marxist government, and the Soviet Union found out, was that the warlords held only the Shah as an authority, who held the tribes of Afghanistan together. With him gone, the warlords did not accept nor obey any authority. Even today, dealing with the tribal factions of Afghanistan are akin to walking on eggshells
Anyway, while I will be the first to say that Carter's administration was the hallmark of terrible foreign policy, I'll also be fair and say this was a bigass can of worms in the making LONG before carter happened on the scene.