Do you even read the Wikipedia articles you link people to? The Afghans were asking for Soviet aid against insurgents backed by the US. The invasion happened when the USSR feared their allies in Afghanistan were not capable of handling the US supported insurgency that they thought would institute a theocracy there as had happened in Iran. Which is exactly what ended up happening there.
That’s not what happened during the US invasion of Afghanistan. That invasion was a cover for war profiteeering, mineral extraction, and opiate production. Rhe US extracted value and resources from that region to enrich capitalists in the imperial core. That’s what makes it imperialist.