OP, almost the exact same thing happened to me about five years ago!
I was on the train headed to the store. A guy gets on the train and I think nothing of it. He is sitting sort of adjacent to me but I stay into my music because I already didn't want to be on the train headed where I was going but had no choice.
So, I was only on for a good two stops (less than ten minutes) and I get off the train oblivious to anything yet fully aware of where I'm at. A womanon her phone rushes up to me and says, "Oh my God! That man on the train was sitting there jacking off to you, girl. I thought you knew. He was staring at you the whole time."
I stand there like, "Wait...what???" At this point the train was gone and so was he. My first thought was why didn't she say something while I was on the train? And, my second thought was that of disgust and how I could not notice somone jacking off right across from me. Sometimes you just like to give people the benefit of the doubt and assume folks aren't just walking around touching themselves all willy nilly.
I was mortified. I now keep a keen eye on who is on pub trans with me. I hate to say it but if you look even the least bit suspicious, I'm getting up and moving somewhere else. I don't care if you get offended or not.