During a meeting with Mr. Trump at the White House on Friday, Mr. Ryan told the president that he was sorry the votes were not there. Mr. Trump bluntly told Mr. Ryan that many people had said he should have gone against the speaker’s advice and pursued a tax code overhaul first, a refrain the president has returned to frequently.

But Mr. Gingrich rejected the idea that Mr. Trump’s presidency would be hobbled by the health care debacle or any of the other setbacks. He predicted that the president would win confirmation of Judge Gorsuch, and noted that even as the health care bill failed, Mr. Trump on Friday reversed Mr. Obama’s rejection of the Keystone XL oil pipeline, a project that is popular among Mr. Trump’s supporters.

“He was the president this morning. He will be the president tomorrow. He has all the advantages that that implies,” Mr. Gingrich said. “He’s having a better presidency than anybody in the Washington media thinks.”

And Mr. Trump is not alone in making early missteps.

President Bill Clinton got embroiled in an early controversy over service by gays in the military. And the effort by his wife, Hillary Clinton, to overhaul health care failed just as spectacularly as Mr. Trump’s did. Mr. Obama lost his bid for “cap and trade” legislation limiting carbon emissions, though that defeat came during his second year in office.

Still, the challenge for Mr. Trump is clear: how to move past the daily turmoil and infighting inside the West Wing and prove that he can use his background as a businessman to advance the policies that he promised as a candidate.

To win an overhaul of the nation’s tax code and a $1 trillion investment in public infrastructure, Mr. Trump will need to find a way to build winning coalitions in the House and the Senate by corralling the often-warring factions in the Republican Party. That may be even more difficult on a tax overhaul than it was on health care, given the moneyed interests watching every proposed change. On some bipartisan goals, the president will have to seize the chance to pick up some Democratic votes as well.