The Iran war, gas prices and Trump’s miscalculations led to one of the most decisive repudiations of an American president.