Yes, the US left Afghanistan because of political reasons, not technical reasons. The US lost the war in Afghanistan. All wars are waged, won, and lost for political reasons. The war in Afghanistan was unwinnable because there was no path to a viable democratic government in Afghanistan. That doesn't have any bearing on the effectiveness of tactical and technical measures.
So tell me what are these political reasons preventing the US from attacking Yemen? Saudi Arabia has been waging war with Yemen rebels for years now, and the US has been helping the Saudis. What exactly is preventing the US from getting even more involved? I'll tell you what: nothing, apart from the fact that the US knows that it will be a losing battle, another Afghanistan, never ending war that would cost the US trillions and would have nothing to show for all that wasted money. And why would it be never-ending? Because just like in Afghanistan the US can't fight guerillas for shit, especially now when the Houthis have powerful allies in the region. So it's all not because of some bullshit 'purely political' reasons but for very practical ones: the US military is simply not capable of decisively winning such a conflict. And that's why they are carefully treading now