If you're practicing a song on the piano over and over again, the idea is that you'll continue to improve. "Practice makes perfect" can be an accurate phrase because the more you do something, you build up that procedural memory and your brain can quickly instruct your muscles to carry it out. That muscle memory doesn't judge whether you're doing good or bad, however, and so if you practice a song poorly for hours on end you're going to be really good at making the same mistakes over and over again. This is not only bad because you've wasted your time learning to be bad or mediocre at a task and may see all this work as a failure, but because you didn't necessarily have to fail at all. When you repeat mistakes again and again, you build a muscle memory with those mistakes. That makes those mistakes even harder to overcome later. This is one reason why the saying "you can't teach an old dog new tricks" is often true.
The key to building good muscle memories is to focus on the quality of the quantity. We've often heard, probably from Malcolm Gladwell's book Outliers, that 10,000 hours is the magic number to make someone an expert. It's likely that this is the case when you practice well, but if you carelessly build procedural memory over and over again you can just end up being really good at repeating your mistakes. When you practice, take it slow at first. Going back to learning to play a song on the piano, don't rush to learn the entire thing. Break the song up into parts and concentrate on learning one part really well. Practice that section slowly until you've got it down, then speed it up little by little until you can play at full speed. More broadly, when you want to learn to do something well, break it into small parts and take each part slowly until you're able to do it very well. Take breaks. Be patient. The more you rush the big picture, the more likely you'll be to develop muscle memories that are difficult to reverse.