Intent
In governing, as in most areas of life, the reason for performing an action is almost as important as the action itself. The Ukraine aid is an apropos example. As many have noted, America can and has in the past, lawfully used congressionally approved foreign aid as an inducement towards desired behavior, including fighting corruption. However, if the purpose of witholding aid is personal rather than national, then the action is corrupt.
If the AG has received evidence that an FBI agent opened an investigation under false pretenses, then prosecuting that agent will generally be seen as duly performing the duties assigned to the AG. If the President tweets: "I think Jeff Bezos should be investigated for how he runs Amazon", and the AG opens an investigation into Jeff Bezos, the people will assume that this is a nakedly political investigation and that the President is abusing his office to prosecute his political enemies.
Do The Right Thing
Now, what happens if the AG receives evidence that Bezos/Amazon was engaged in wrongdoing, and decides to open an investigation, but before making it public, the President tweets: "The AG must look into that no-good thief Jeff Bezos who publishes lies about me and stops America from being great again!" At this point, the AG cannot carry out a proper investigation and possible prosecution without appearing to be a political pawn of the President. The President, with a single tweet, can illegitimatize an otherwise legitimate investigation. Of course, the tweet doesn't make the investigation illegal or wrong, and ethically, the AG should still pursue it. But following the correct course of action results in the AG's office losing the trust of the American people, because it appears to be a stooge of a corrupt executive. It should go without saying that maintaining the trust and confidence of the American people is a fundamental obligation of all government workers.
Note that it doesn't matter that the AG can publicize the evidence of wrongdoing in trial, or even in the media at some point. Much of the population will assume that some to most of the evidence was manufactured to please the President and determine a particular outcome, eroding American's faith in the very notion of justice at the federal level (and by extension, at all levels).
No Confidence
Conversely, when the President undermines the AG with a tweet, it causes the rest of the Justice Dept. to question whether the AG is acting properly. After all, if the CEO of your company undermines a Senior Vice President in a company-wide email, I can guarantee you that everyone reporting into that SVP is going to think twice about orders handed down from that executive. At the very least, following the SVP down the Trail of Displeasure is surely going to be career-limiting at some point. Similar effects occur in gov't, because it's an organizational/social phenomenon, rather than a business one.