Germany just had Pimmelgate (Pimmel is a synonym for penis). Hamburg's Senator of the Interior did something and some random guy wrote "you're such a dick" ("du bist so 1 pimmel"). The Senator apparently was very annoyed and asked the state attorney to go after the guy. They summoned him to the precinct, he went, said that he wrote that tweet and declined to say anything else without a lawyer present. They then got a judge to sign a search warrant against his ex-girlfriend (and mother of his children who live with her), and executed it, which was unnecessary (they knew who did it and he had already confessed) and meant to punish extra-judicially since the case would likely be thrown out in court.
The state attorneys and police are part of the executive branch and subject to directives of the politician in charge. Theoretically, electing the state attorneys directly would motivate them to not just do whatever the administration wants, be that legally reasonable or not. In practice it probably does not matter.