Treat focus like a skill you develop, or a muscle that you train to be stronger. If you wanted to improve your weightlifting you would schedule regular gym visits and create a plan to do a certain amount of lifting each day with slightly more weight each week. If you wanted to improve your running you’d set aside time to run and try to run incrementally farther over time. Focus is the same: You need to start small, schedule time for it, and work your way up. You can’t expect to run a 6-minute mile or benchpress 400 lbs without practice, so you shouldn’t expect to sit down and focus through completing multiple side projects quickly without building your way up to it.
Start with incremental goals. If you only consider goals that are too far out of reach for your current focus conditioning (finishing multiple entire projects) then you’re only going to get frustrated. Break projects down into incremental milestones and set intermediate goals to reach each milestone. Decompose into individual features and track them in a simple project management software if it helps.
You want to get to the point where you can sit down at your computer, know what task you can work on next, and have that task be small enough that you can finish it in one sitting or one evening. Practice breaking down your problems into smaller and smaller portions until you reach this goal.