I vividly remember an instance, a few summers ago (pre-pandemic), when I had walked down to my local post office to drop off a batch of letters. This older guy standing on the sidewalk just struck up a casual conversation with me. Then, suddenly, he saw a young woman approaching her car on the sidewalk in front of us; he clearly found her attractive, and called out to her, "Hey! You're really hot!"
Standing next to him, I could read her body language that she was clearly uncomfortable and disturbed. She shrank into herself as she headed toward her car (so she could get in).
The guy had watched her reaction, and he remarked to me, "Oh. I guess she doesn't like compliments."
And I said to him, "Well, she doesn't know you. Not everyone feels comfortable talking to strangers."
And, with a big grin, he rebutted, "But YOU talked to me!"
To which I replied, "Yeah, but I'm perhaps more gregarious than most people are."
He responded, "Gregarious? Now there's a word you don't hear very often. What does that mean?"
And, out of the corner of my eye, I could see the young woman getting ready to make her getaway as she reached her car door.
So I just basically kept him talking, distracting his attention, so that he couldn't say anything else to her as she proceeded to extricate herself from the situation.
I don't know if I did/said the "right" things, but it was the best I could think of -- in the spur of the moment -- to diffuse the situation from potentially escalating.