Their weak candidates, identity politics and extremism pushed voters toward the ex-president.