Judges say prime minister must abide by attorney general's opinion barring him from involvement in filling roles that may have bearing on his criminal cases