The scene in the movie is an amalgamation of two seperate instances in the book during which Harry heard the mysterious voice. Finding Mrs. Norris takes place on Hallowe'en in the book, so all the other students are returning from the Feast, which is the reason they run into three constantly troublemaking students standing next to a recently petrified cat ...
Turning my comment into an answer as requested:
The situation is (at least a bit) clearer - or maybe less contrived - in the book, where all this doesn't happen after Harry's detention with Lockhart, but after Nearly-Headless Nick's 500th Death Day Party, which takes place concurrently to the Hogwarts Hallowe'en Feast (since Nick died on October 31, 1492).
All the other students obviously attend the Feast, which runs longer and is more oppulant than the regular evening meal. In fact, Harry, Ron and Hermione hear the feast is still underway when they arrive back in the entrance hall after leaving the Death Day Party, but Harry doesn't care, since he is following the sound of something else:
“Let’s go,” Harry agreed.
They backed toward the door, nodding and beaming at anyone who looked at them, and a minute later were hurrying back up the passageway full of black candles.
“Pudding might not be finished yet,” said Ron hopefully, leading the way toward the steps to the entrance hall.
And then Harry heard it.
“…rip… tear… kill…”
It was the same voice, the same cold, murderous voice he had heard in Lockhart’s office.
This is exactly the point were two seperate instances Harry heard the voice in the book are merged / meshed together in the movie, most likely to tighten the plot. In the book the detention itself happens in the previous chapter and plays out pretty much the same as in the movie. In the book Harry returns to the dormitory without incident after the detention.
He stumbled to a halt, clutching at the stone wall, listening with all his might, looking around, squinting up and down the dimly lit passageway.
“Harry, what’re you—?”
“It’s that voice again—shut up a minute—”
“…soo hungry… for so long…”
“Listen!” said Harry urgently, and Ron and Hermione froze, watching him.
“…kill… time to kill…”
The voice was growing fainter. Harry was sure it was moving away — moving upward. A mixture of fear and excitement gripped him as he stared at the dark ceiling; how could it be moving upward? Was it a phantom, to whom stone ceilings didn’t matter?
“This way,” he shouted, and he began to run, up the stairs, into the entrance hall. It was no good hoping to hear anything here, the babble of talk from the Halloween feast was echoing out of the Great Hall. Harry sprinted up the marble staircase to the first floor, Ron and Hermione clattering behind him.
Harry Potter and the Chamber of Secrets, Chapter 8, The Deathday Party
Coincidentally, or rather for plot convenience, but at least with some probability, the Hallowe'en Feast finishes just in time for all the school to run into Harry, Ron, Hermione and the petrified Mrs. Norris hanging around.
However, it doesn't exactly make much sense in the book either... because Malfoy is there, which is ridiculous, because Myrtle's bathroom is on the 2nd floor, whereas all the Slytherins should have gone downstairs from the Entrance Hall to the dungeons instead of upstairs. Yes, Draco is pushing himself through the crowd - as he does - but he arrives a bit too quickly for him not having already been on his way up (which of course helps in getting the reader to suspect him as being the Heir of Slytherin, so in the end it does make sense narratively).