Is there any idiom to describe the importance not to let somthing bad happen in the first place

I think it is well known that if we indulgently let something bad happen, there will be more similar cases arising. The outbreak of the negative effects could be unstoppable. So is there any idiom, proverb or fancy expression used to stress this point.


There is

A stitch in time saves nine.

and

Don't spoil the ship for a ha'porth of tar.

and also

For want of a nail, the shoe was lost;
For want of the shoe, the horse was lost;
For want of the horse, the rider was lost;
For want of the rider, the battle was lost;
For want of the battle, the kingdom was lost;
And all from the want of a horseshoe nail.


There is also an expression

the thin end of the wedge

for which Merriam-Webster has

the beginning of something that will become more serious, unpleasant, etc.
The bank's decision to raise rates could be the thin end of the wedge if other banks follow along.


A quotation sometimes attributed to Benjamin Franklin is An ounce of prevention is worth a pound of cure.


Depending on the context, this idiom might work

One rotten apple spoils the barrel