Usually the sunglasses are used to prevent from the uv and other bad lights. They are usually in the strong sun and on the beach. However, some people wear sunglasses at gym. They just want to show the cool personality and cool appearance. In addition, the sunglasses are really the good accessories.
It seems that you have been to a great place, because only some well equipped gyms have such strong lights which are able to tan your body and make your skin look better and healthier anyway. So, the reason why they wear sunglasses is to protect their eyes from the strong tan lights, because they are harmful to their eyes. On the other hand, maybe they tend to be cool with sunglasses on.
I have to say, yes, for most cases. But there still lots of reason like avoid the straight eye contact with someone, or make it as a disguise of which their eye disease would be exposed in public.
So you can see that, there can be several reason, don't be so curious about other peopleâ€™s behavior, and focus on your own.