Cliche warning. Admitting that you have a problem is the first step.

Most young people are like this. You're not unusual. Difficulty focusing is pretty normal, but you do have to do something about it if you want to achieve anything.

I hate to break it to you, but the corporate world makes it worse. Now you're surrounded by unfocused, capricious, and disengaged people in a world where the worst people tend to have the most success. You need to take that for what it is: a motivating negative example, how not to live and what not to become.

When you're young, you wonder why most people never accomplish anything. Now you're getting older and seeing why. Lack of focus. Career incoherency. Bad management. Low drive. People let their time and energy and engagement get nickel-and-dimed by the world and soon there's nothing left.

You've learned a lot in 2 years. That's great! You've probably gotten more out of the past 2 years than 95% of people; but if you want to run with the elite (I'm not elite; I spend way too much time on activism, but that's another story) you have to up your game even further. Up it again. And again.

Perfectionism is something that comes to us from schooling, I believe. You work on something, then you "turn it in", and you get your one final, seemingly life-altering, piece of feedback: a letter grade or a score between 0 and 100. School also encourages risk aversion, in so far as tests ask easy questions where the average person gets 75-85% right, which means that 1 total failure (0%) counteracts 5 excellent projects or aced exams. (This is not universal; in the UK, exams are harder but 70% is an excellent score.) If I were to redesign the system, tests and projects would be very hard but 20% would be passing and 50% would be an A... but that's another rant. In the real world, that "work for months then 'turn it in'" strategy leads to demotivation, anxiety, and (as you've experienced) perfectionism. You need to find people you trust and link up with them to get constant feedback. This is why the REPL (interactive mode) of modern languages is so important; without interactivity, you don't learn anything and become disengaged.

You have to change yourself if you want to achieve anything. You're experiencing the processes that cause so many people not to achieve anything, but at least you're aware of it. You have to form better habits. Work, and sleep, and exercise, in the same hours every day. Have a principled schedule for taking breaks. Get up at 5:00 if that works for you. Exercise every day (it helps). Establish a routine because if your life is constantly full of injections and senseless change, you'll constantly be cleaning up your own spilled apple carts. Curtail (or cease) drinking.

You need to form better habits and establish a routine of getting stuff done. Just remember that each action counts for about 10, insofar as people are creatures of habit and what you do now also influences how you will behave when you are tired and falling into default activities (self-control is hard and limited and 70+ percent of your time will be in default activities, so make those better). What differentiates the true high-achievers from the rest of us is that they program themselves (often unconsciously) to have useful default activities, instead of watching TV or playing video games.

That's not to say there's anything wrong with TV and video games in moderation. I love Mad Men and Breaking Bad, and I probably play an SNES RPG (those are good because they're time-limited at about 50 hours) every year or so. You just don't want those to become your default time-filling activities. If you want to be a top-tier technologist, your default activity should be something related to technology.