Not gonna lie I don't go to gyms either lol, I'm not sure myself. Though tbh sometimes people do socialize there from my understanding, there's classes people will do together like yoga and stuff, and in some of those there's some socialization I think. And in the case of the homosexual community, apparently quite a bit, the Equinox saunas in NYC at least have a reputation of being a popular cruising spot.
As far as why I'm under the impression that you're not supposed to, women complain about it a lot, and getting asked out anywhere else too. It seems the general consensus is the only acceptable places to directly speak to a woman without an intermediary are on hook up spyware apps and at the bar. Failing that, "get a hobby and try to make friends, then beg/hope those new friends set you up with someone." "Go to the gym" is often still given as bad advice because it used to be acceptable but I think those must be olds behind the times or gay men, because those days are gone.
"Get a hobby" has it's own problems, first of all it's just as outdated as the gym (which to many is a hobby but ignore that), second it assumes you must not have any hobbies if you're single which frankly is a baffling line of thought to me lol.