What is a word that describes when you try to fix something bad but destroy something good in the process?

Solution 1:

Situations as the one you are describing are generally referred to as:

out of the frying pan into the fire (saying)

when you move from a bad or difficult situation to one that is worse

(Cambridge Dictionary)

Solution 2:

To throw the baby out with the bathwater. LINK

To discard something valuable or important while disposing of something considered worthless, especially an outdated idea or form of behavior.