Two 18-year-olds suspected of carrying out a robbery were arrested after armed officers tracked them as they boarded a train.