When I used to teach beginning programmers, I would tell them they should plan to write at least 10 other programs before they started writing the program they were thinking of writing. The reason for this is simple: practice. Those 10 other programs are practice programs, where you learn how things really work, what to do, what not to do, and also learn critical skills like decomposition (breaking things down), composition (building things up from smaller parts), and debugging (finding and changing the parts where reality doesn't match expectations). There's an old adage in programming: Plan to throw one away, you will anyway.
I have had students who insisted that they didn't need to wrote those 10 other programs. They often became frustrated when they encountered situations where a solution was needed but they didn't have the skills or knowledge to know how to make it (simple example: the linked-list data structure). They were also frustrated because they would repeatedly revisit, fix, and revise earlier parts of their Ultimate Program, because those parts were written when they were unskilled. Either the design was terrible, the logic was flawed, or it was riddled with bugs (buffer overflows being a common one; yeah, it's C). Constantly repairing the same work to fix errors of ignorance is demoralizing. Sisyphus was a programmer.
By the way, even after you become decently skilled and with years of experience, you'll still find you're revising old code you wrote, fixing flawed logic, and finding bugs. You do get better at avoiding stupid or obvious mistakes, but there are still plenty of advanced or subtle mistakes to make. The universe of Getting It Wrong is larger than the universe of Getting It Right.
An analogy I used to use is that no one starts out driving cars by entering the Indy 500. Heck, you don't even start by entering a street race. You first have to learn how the pedals work, how to shift (if you're using a manual), and how steering works at different speeds. That doesn't mean that having a goal of eventually racing is misplaced, it just means you've got lots of training and practice to go through to get there.