Every time I fail like this, it's because I tried to do too much too fast and it wasn't sustainable. If it's not sustainable, it's inevitable that you'll quit.
For me it's been a mistake to focus on the goal (i.e. don't focus on "lose 30 pounds"). Instead, establish exercise as a daily habit, regardless of the goal. Set aside the time to do it every day at the same time of day, a sustainable amount of time (not too much!). Ramp up slowly, don't injure yourself, don't get impatient, just do a little every day. Mentally commit to doing it for the rest of your life. Don't think of it as a thing you're doing for some other purpose, just think of it as part of your life that you must do every day.
It took a few years of weekend hikes before I was willing to make a commitment to walk a whole 1 hour every day -- and the only reason I did that was because I was going to do a multi-day high-altitude hike (EBC trek) and I knew from experience that if I didn't train for it then I'd probably not complete it. It was a decade before I moved on to other forms of exercise -- it's a very long process!
Someone else mentioned you should cook all your food. I agree, cooking your own meals is an amazing habit with some key benefits (not just nutrition). It provides instant gratification and also once it's established as a habit then you can use it as an exemplar for how to establish other daily habits.
Edit: By "exemplar" I mean that you need proof to yourself that a small gradual habit will eventually lead to the benefits you want from it. It's not easy to see the worth of delayed gratification that doesn't come to fruition within a few months. It requires "faith". Having gone through the process once will give you the proof you need to have faith that you can do it again.