Most district attorneys are law-abiding advocates for the public interest who want to protect the people around them. Some, however, use their position as leverage to intimidate or punish people. Some, purposefully or not, choose to prosecute a bad arrest and case with bad evidence.
In either of these cases, the attorney may have committed malicious prosecution. Malicious prosecution is often punished via civil lawsuits that do two things: bring to light the prosecutor’s misdeeds and award financial compensation for their victims.
Most cases that don’t have sufficient evidence to prosecute aren’t brought to trial. If a case that lacks sufficient evidence is brought to trial, it can be considered malicious prosecution.
More egregious cases of this involve a prosecutor using their power to file charges in order to harass, shame, intimidate, or defame someone. It can also include filing charges for a crime in order to cover up for the person that actually committed it.
Whether accidental or purposeful, filing charges against someone without evidence should be punished.