Other presidents have been criticized for offering public verdicts about pending criminal cases. In 1970, President Richard M. Nixon declared that Charles Manson “was guilty, directly or indirectly, of eight murders without reason” in the middle of his trial in the killings of the actress Sharon Tate and others.

By the end of the day, the Manson team’s lawyers had moved for a mistrial, citing the president’s remarks, and Nixon issued what his press secretary called a “clarification” taking them back.

“The last thing I would do is prejudice the legal rights of any person, in any circumstances,” Nixon said. The defendant later held up in court a newspaper with the headline “Manson Guilty, Nixon Declares.” But the judge allowed the trial to proceed, ultimately ending with a conviction.

In 2005, Mr. Bush expressed confidence that Representative Tom DeLay of Texas, the former Republican majority leader, would be acquitted, weeks before his trial on money laundering charges was to open. “I hope that he will, because I like him, and plus, when he’s over there, we get our votes through the House,” Mr. Bush told a television interviewer.

His successor, Mr. Obama, forecast an execution for Mr. Mohammed, the Sept. 11 detainee. Defending the later-aborted decision to try Mr. Mohammed in civilian court rather than a military tribunal, Mr. Obama said critics would not find it “offensive at all when he’s convicted and when the death penalty is applied to him.”

The impact of such comments is more pronounced in military justice cases since the president is the commander in chief of the judges and juries that determine guilt or innocence and hand down sentences.

Responding to a wave of sexual harassment allegations in the military, Mr. Obama declared in 2013 that troops who commit sexual assault should be “prosecuted, stripped of their positions, court-martialed, fired, dishonorably discharged.” In this instance, he was not commenting on a particular defendant, but lawyers nonetheless argued that it constituted “unlawful command influence.”