Many stupid or biased judges will do anything, procedurally incorrect or legally disallowed, with haughty attitude, often stated of “take me up”.
What do they care? They are hard to get rid of. If over ruled a number of times, many in the profession of law just laugh about it.
And from what I've read, prosecutorial malfeasance is rarely ever punished, so they just continue with their underhanded, illegal activities.