Im not sure how you define defeat. The USSR never controlled the country as a whole. Neither did the USA. So arguably neither won in Afghanistan. If you don’t win, you lose.
USSR did suffer a lot more loses significantly attributable to US involvement. Something USA did not have to deal with...