The vote marked another embarrassment for Trump, who was shown the limits of his sway over House Republicans.