The former president’s comments also reflect his own policy legacy, which has come in for modest questioning and criticism at times by some Democrats in the debates and on the campaign trail. (One friend said Mr. Obama had brushed off debate criticisms, joking that the eventual winner will “come back to me when they need me.”)

Sign up for On Politics to get the latest election and politics news and insights. Sign up for our politics newsletter

Mr. Obama was initially reluctant to attack Mr. Trump after he left the Oval Office, in part because he wanted to embrace the informal practice adopted by his predecessor, George W. Bush, of not attacking a presidential successor, former aides said. But he was also concerned that going after Mr. Trump would play into Republicans’ hands by prompting a backlash, they added.

By the 2018 midterms, Mr. Obama abandoned that reticence and campaigned aggressively against Mr. Trump, emboldened by the president’s halfhearted response to his attacks.

He also offered vague praise for the large-scale health care policy that Mr. Sanders and Ms. Warren are now championing. “Democrats aren’t just running on good old ideas like a higher minimum wage, but they’re running on good new ideas like Medicare for all,” he said in a speech at the University of Illinois in September of 2018.

The big difference now is Mr. Obama’s willingness to publicly criticize others in his party, however indirectly, something he had avoided.

Katie Hill, a spokeswoman for Mr. Obama, said that he was not targeting Mr. Sanders or Ms. Warren in his remarks last week, and that his public declarations in support of the Democratic field and a diversity of opinions are the core of his message.

“Since leaving office, President Obama has worked to stay out of the political fray in part to let other, new voices in the Democratic Party rise up,” Ms. Hill said on Wednesday. “Just like in 2018, he’ll be out on the campaign trail next fall working hard for whoever our nominee is.”