People started repeating this thanks to the New Hanover Gazette article that you can read after the Scarlet Meadows train heist.
"Who are the Scarlet Meadows Bandits?":
Gertrude Bambach was knitting a hat for her niece when the train lurched to a stop and shouting commenced. "I fear for my life," she said. Passengers were subjected to a terrifying ordeal as the train was robbed near the Lemoyne border. Outlaws used an oil wagon on the tracks to cause the train to come to a stop. They then threatened the passengers to give up their belongings. *It was then that lawmen, having been tipped off to the robbery, arrived on the scene and confronted the outlaws.*
Sheriff Thomkins was one of those lawmen who arrived on the scene. "There is very little to tell. We are searching for evidence at this time. The passengers are in great distress. The supply cars have been looted. Men are dead. This region's problems with lawlessness have returned."
Reports indicate the outlaws escaped after having engaged in a furious gun battle with the lawmen.
1. Did John Marston gained something by doing that? John Marston wasn't gaining anything from tipping the law off, the "cops" shot at everyone involved in the robbery, and John Marston hadn't fled during the Blackwater chase, why do that after what happened? Plus, John Marston had a good amount of heat on him because everyone knew who participated in the Blackwater Massacre. It is also necessary to clarify that he was always in the camp before the robbery, then he arrived accompanied by Charles when it was time to commit it.
2. People speculate that he allowed himself to be captured in San Denis to give more information to the police. This is false, we only need to analyze the order in which they left the bank to notice that he was alone and that being only one member left inside the bank giving cover to the others, it would be easy to capture him, both entrances to the bank were also being covered by the police. John Marston was also held for a while in jail instead of being executed immediately. This can be explained if we look at the relationship between Cornwall and the Pinkerton Agency, after several robberies to Cornwall's trains and a stagecoache, and that Valentine Massacre, the Pinkertons had found the gang in Clements Point but they quickly moved to a new location after Agent Milton's warning, this was the 2nd time that the gang had escaped from the Pinkertons, and judging by Cornwall's insistence on executing the gang off, it was obvious why he was mad at Agent Milton in Chapter 6. So John Marston was most likely held at Sisika Penitentiary for questioning, and to know the whereabouts of the Van der Linde gang, or to offer him a "Michael Townley deal".
Side Note:
The line of the newspaper article that mentions "It was then that lawmen, having been tipped off to the robbery" could actually mean what Arthur Morgan suspected after escaping, he believed that the armed posse of gunmen they first encountered could've been just locals that were passing through Scarlet Meadows at the time of the robbery, then the actual posse of Lawmen showed up and chased them.
The explanation of why the police knew about the robbery is quite simple. At the end of the mission, Arthur canonically mentions that the Pinkertons had found him when he was in the river with Jack, knowing the Pinkertons that the camp was in the area and that the gang was escaping from committing a train robbery, which belonged to someone wealthy, they only investigated if there was something that could catch the attention of the gang and they found a train that would pass through Scarlet Meadows that week, the same train that Mary-Beth came to know about through an outside conversation. From what Mary-Beth heard, this train would be loaded with wealthy passengers plus their belongings in the luggage cart. The Pinkertons are detectives after all, there was also an experienced detective at Shady Belle that noticed the hidden message in Sadie's letter, while the rest didn't, which is how they found Lagras (killing those agents is optional).