Is there a term for when a cure or solution to a problem becomes a bigger problem

Scorched earth.

Now that you asked the question I feel there should be an exact term for this.

The colloquial name is “old lady who swallowed a fly syndrome”.

Collateral damage.

My Daddy used to call it a ‘clusterfuck’, or ‘Beckdawrek’

I’ve also heard ‘emergent behaviour’ related to the cobra example. Though that doesn’t strictly have to have negative results, just unexpected/non-obvious ones. Flocking in birds or schools of fish can be modeled by a few very simple rules.

Edward Tenner used the term “Revenge Effect”. See short book review at:
this link.

He was mainly talking about technological solutions to problems making the problem worse. It’s a narrower category than “unintended consequence” because an unintended consequence can be sideways rather than backwards.

Now that we’ve had sufficient on-topic replies, lets have a nice poem