I have been working out on and off since I was a teen. However, I never have been compliant with routines for over a year at a time. It seems to be a psychological thing. Because a hardship in my life happens, and then I quit for a period. Is it because I lack resiliency?
Well if you have to ask... Just kidding. If you're able to keep up a routine for a year that sounds actually like your ability to stick to things pretty well. You could call it mental toughness but that's built over time, over a lot of small decisions. The mind and body are very good at falling into habits and routines, good or bad.
A few things that help me stick to and enjoy working out:
Attach workouts to an existing part of your daily routine.
For example, I've been getting up and going to the gym at 4 am every day before work/school for the past decade only missing a day if I'm too sick to work. Think of it as just part of the workday, don't allow yourself to skip it unless you're not going to work. Even if 5 days a week is too much I still suggest going and doing a lite activity outside the house just because giving yourself a day off will make so you're leaving your schedule/mind open to days off. Leave at the same time to the gym and leave the gym when you're ready to go to your next part of your day.
Mix in other types of activities.
Preferably ones you haven't tried before, learning a new skill and improving are great motivators. It could literally be anything, biking, rock climbing, surfing, swimming, join a sports team, etc. I've spent a few years before getting addicted to rock climbing after trying it once, going climbing outside or in the gym 6 days a week for years. This could be a good substitute to if you want a day off the gym.
Commit to an event or goal.
An outstanding motivator is committing to some sort of competition or goal. For example sign up for a 5k+, lifting comp, sports team, mud run, etc. You'll never train as hard as you do when others are depending on you performing, or you don't want to embarrass yourself. This may be temporary but just pick another one once you're done you may get really into it.
Then hopefully if a wrench is thrown into you life workouts will be the last thing you want to get rid of.
Yes, welcome to the human experience. Living this modern cushy life has it's ups but there are downs too where the cost for mental weakness is relatively low enough to keep it going.