When Snape interfered and told Malfoy to return to the dungeons and that he would follow him in a moment, Hermione saw her chance. She snuck out within seconds after Malfoy had left and hurried after his quickly disappearing figure.