Nip-in-the-bud Definition

verb

To remove a bud from a plant to prevent flower and fruit from forming.

Wiktionary

(idiomatic) To stop something at an early stage.

If you see a bad habit begin to develop, try to nip it in the bud so that it does not become ingrained, issues are easier to sort out the earlier they are addressed.
Wiktionary