So you’re trying to learn a new melody on your instrument.
Or a new boogie bass line.
Or, less glamorously, a scale. Or an exercise to improve your technique.
You want to get playing it up to speed, so you try it faster and faster until you get it once at a decent pace. But you can’t seem to repeat it. Something keeps going wrong.
Why?
Here’s the why.
You have practiced it until you got it right – and that’s fine. But you need to practice it until you don’t get it wrong.

So in the above instance, your first priority should not to be able to play whatever you’re trying to play fast, but to be able to play it accurately, and repeatedly. Tempo is irrelevant at this point. It just needs to be slow enough so that it allows you to get the fingering right, get the feel right, in a relaxed manner and in a way that you can do the same thing over and over again.
Now it’s starting to get into your muscle memory, and only then do you increase the tempo.
With a metronome. Bit by bit. Don’t move on to the new tempo until you can play it accurately 5-10 consecutive times at the previous tempo.
And don’t dare move on if your accuracy and feel are being compromised.
You can choose what becomes a habit. The right way to play something, or the wrong way. It’s up to you.
So correct your mistakes before they become habits.