The fact as to whether there was danger or otherwise is immaterial. Women have the right to go about the banal mundanities of their daily business, without constantly being accosted by male strangers for no good reason. And it IS constant. I, too, have experienced the impromptu male swimsplainers - must be a common phenomenon - and responded sarcastically that I'd earned my bronze swimming certificate, and the gym instructors had severe competition if random club members were so willing to offer their 'expertise' (air-scare-quotes inserted for emphasis) completely for free
I mentioned the danger because other posters were making up arguments the OP did not.
I expressly stated that, if the OP did not welcome the advice, she could have perfectly well told this guy to stay away without reporting it to anyone. Many people who choose as sport weights in a gym are introverts and may not feel comfortable with anyone talking to them.
However, if you decide to go to a gym it is likely someone else will talk to you about some gym related stuff. Giving 'advice' is pretty normal and anyone who has gone enough to a gym would know this.
You may not like it at all. Obviously the OP dealt with it herself. I would never be rude to someone at random (I actually think men should behave more like women and not viceversa when it comes to be polite and avoid phyical and verbal violence of any kind). And I still believe that, in this scenario, reporting to the gym is overreacting.
Since it seems necessary to clarify this to all women who are treating me like a bit 'slow' in understanding what is written and despite some suggestions here I am a woman. Believe me I know what unwanted/undesirable male attention and mansplaining involves.