An investigation has been launched after a passenger was forced to run alongside a moving train with their hand trapped in a door.