I belong to a Crossfit gym, because psychology.
1. I am lazy and always find excuses not to go upstairs to the elliptical or outside for a walk -- it's easy to procrastinate until it's too late to do anything. Whereas if I have a set class time that I have to sign up for in advance, I force myself into a commitment that is harder to bail out of when the time comes.
2. I am cheap, so if I am spending $150/mo. on something, I am much more likely to make myself go to get value for the money.
3. I really, really love lifting heavy shit and doing strongman stuff. I am also old and don't have 30 years' experience doing it properly. I like the security of knowing that I have experienced supervision from trained coaches to keep me from injuring myself because stupidity, ensure I have spotters to keep me safe, and that someone who knows about this stuff is maintaining the equipment, keeping it clean, etc. (and it's a small, neighborhood gym, so I know the owner/coaches and know how it's maintained).
4. I like the gym's programming, which cycles through an intentional program that considers a bunch of different things (muscle groups, cardio/strength, flexibility, cycles of focusing on specific lifts, etc.). It means I don't have to think or research, just do what I'm told.
5. As much as I am not a joiner in general, these people make me feel like a badass. I have never felt physically proud of myself -- the classic too much weight, lack of cardiovascular capability that turns out was undiagnosed exercise-induced asthma, etc. These guys get me out of my head, never criticize me, but instead always praise effort and notice new personal bests and such.
6. It is a huge emotional outlet. I am always, always the grownup in the room, at work and at home, so I always have to have a filter and manage my emotions in a mature, productive way. When I go to the gym and discover Chris has programmed burpees, I can bitch and moan about how much I hate burpees, swear my head off if I feel like it, and everyone just laughs. It is my "safe space" to be the real me.
7. It's 2 blocks from my house. For a while I belonged to the Y, but I had to drive there, and making a left turn out of the parking lot to get home after was fucking impossible. More convenience = much more likely I will go (see "lazy" above).
In a way, it's kind of like saving money and managing a healthy diet, except that saving money comes naturally, while eating right and working out do not. If I set my life up so hitting the gym becomes the default and minimize opportunities for immediate gratification to lead me astray, I wind up more successful than if I just try to willpower my way through what I know I "should" do.