This habit of "moving stuff around" in the code, or what some refer to as blind tinkering, is not useful when that's all you're doing. I know that playing with the code is a great way to learn, but it should be done methodically and with the intention of caring about what you're learning. That is, either while or after you've played around and got the desired result, draw reusable conclusions as to why that experimentation was useful.
So I'm trying to build the practice in which I encourage myself to constantly ask questions like, "What do I know so far?", "Do I really understand how each line of code works?", "How else can I better organize what I've written?", and most importantly, "Am I just blindly tinkering?". Ask yourself these questions, think about the code, recognize what mistakes you made during the experimentation, and avoid blind tinkering. This type of concentration is key before declaring the job done and moving on to the next task. Doing this has not only provided me with a richer learning experience, but with more confidence in what I know.
For me, the value of the final product now also lies in my complete understanding of the code itself. I suspect that if this mindset becomes habitual, I can fulfill the role of an expert beginner in no time.