House Speaker Mike Johnson appeared headed for defeat before two Republicans switched their vote, delivering him a majority.