Judges are supposed to be unbiased, everyone can agree. But determining whether a judge's views or experiences give rise to actual or apparent bias is often up for debate. Legislatures and bar associations have rules on when judges should be disqualified from cases. But not all states have similar rules, and not all rules are equally strict.
In June 2016, the U.S. Supreme Court issued a decision that applies to at least one scenario of potential bias: where the judge was once involved as a prosecutor. The rule is this: A judge who has had “significant, personal involvement as a prosecutor in a critical decision regarding the defendant’s case” must be recused. (The case involved an appellate judge who had been, many years earlier, the prosecutor who approved the decision to seek the death penalty against the defendant.)
You can read about the case, Williams v. Pennsylvania (579 U. S. ____ (2016)), in Can a Judge Who Once Prosecuted the Defendant’s Case Preside Over It?