Mr. Trump’s difficult adjustment to the presidency, people close to him say, is rooted in an unrealistic expectation of its powers, which he had assumed to be more akin to the popular image of imperial command than the sloppy reality of having to coexist with two other branches of government.

His vision of executive leadership was shaped close to home, by experiences with Democratic clubhouse politicians as a young developer in New York. One figure stands out to Mr. Trump: an unnamed party boss — his friends assume he is referring to the legendary Brooklyn fixer Meade Esposito — whom he remembered keeping a baseball bat under his desk to enforce his power. To the adviser who recounted it, the story revealed what Mr. Trump expected being president would be like — ruling by fiat, exacting tribute and cutting back room deals.

But while he is unlikely to change who he is on a fundamental level, advisers said they saw a novice who was gradually learning that the presidency does not work that way. And he is coming to realize, they said, the need to woo, not whack, leaders of his own party to get things done.

During his early months in office, he barked commands at senators, which did not go over well. “I don’t work for you, Mr. President,” Mr. Corker once snapped back, according to a Republican with knowledge of the exchange.

Senator Mitch McConnell of Kentucky, the Republican majority leader, likewise bristled when Mr. Trump cut in during methodical presentations in the Oval Office. “Don’t interrupt me,” Mr. McConnell told the president during a discussion of health care.

—Maggie Haberman, Glenn Thrush and Peter Baker, Inside Trump’s Hour-by-Hour Battle for Self-Preservation