I would think so too, but in practice it seems that gyms work for people because it's a whole function that's easy to compartmentalize unlike doing push-ups next to your bed. I think it's less mentally taxing.
e.g. I would wager that going to the gym to use the chest press machine is more realistic for most people than suddenly being able to do push-ups in their living room during a TV commercial or whatever.
These reflections come from my own experience trying to get friends to do body-weight exercises with me, and my own journey from going from a gym guy to the guy who is doing push-ups while waiting for my HEB steamables bag of edamame to cook in the microwave. For various reasons due to, I think, our human nature, the latter is a lot harder and requires more personal transformation. Doesn't seem like it should be though.
I think one way to begin thinking about this is: to everyone in these comments who is supposedly very opinionated on exercise and health, what stopped you from doing 20 push-ups on your apartment floor today? We have all sorts of reasons.
For people who want to become especially strong, specialized weights and machines become more important, but as a percentage of the population this group must be vanishingly small. The "do a little each day" thing certainly lends itself better to calisthenics, which can be performed almost anywhere, than to a gym.
I expect a typical person would have better luck doing body weight squats 5 days a week at home than trying to stick to a gym schedule to do barbell squats regularly.