A suspect was taken into custody after the attack, which unfolded around 7 p.m. in one of the nation’s busiest transportation hubs.