In your examples, it would most likely be a Mistrial scenario, the jury would be dismissed, and the prosecuting team would have to start over again from scratch later, assuming they aren't themselves in trouble for introducing faulty evidence.
I’d be really curious to hear about a case where prosecutorial misconduct was punished. Don’t they have something akin to the “qualified immunity” that the police enjoy?