In the book, when the fellowship enters Moria, Frodo begins to detect that something is following them. He begins to hear footsteps after they have stopped and "feels" that something is following them as they travel through Moria. As far as I remember he never mentions this to anyone else in the group (it turns out to be Gollum). But why was he the only one to detect this? I don't remember it being mentioned that hobbits have better hearing or sight than other races. Even if this was the case, none of the other hobbits detect Gollum's presence.
Aragorn also detected him, and in fact there is evidence that it is Aragorn who had detected him before anyone else (as one would expect for a Ranger) (from the Great River):
'What is it?' he whispered, springing up and coming to Frodo. 'I felt something in my sleep. Why have you drawn your sword?'
'Gollum,' answered Frodo. 'Or at least, so I guess.'
'Ah!' said Aragorn. 'So you know about our little footpad, do you? He padded after us all through Moria and right down to Nimrodel. Since we took to boats, he has been lying on a log and paddling with hands and feet. I have tried to catch him once or twice at night; but he is slier than a fox, and as slippery as a fish. I hoped the river-voyage would beat him, but he is too clever a waterman.'
It's also Sam that sees the "log with eyes" elsewhere in the chapter, and the evidence emerges during their subsequent conversation that Frodo may have only really began to suspect after their entry into Lórien:
'Yes, that is what I have feared for some time,' said Frodo. 'Ever since the night on the flet. I suppose he was lurking in Moria, and picked up our trail then; but I hoped that our stay in Lórien would throw him off the scent again. The miserable creature must have been hiding in the woods by the Silverlode, watching us start off!'
Regarding Frodo's hearing the footsteps in Moria, it's notable that this scene is told from Frodo's point-of-view:
Frodo's spirits rose a little; but he still felt oppressed, and still at times he heard, or thought he heard, away behind the Company and beyond the fall and patter of their feet, a following footstep that was not an echo.
Since we don't get Aragorn's point-of-view, nor that of Legolas or Gimli, we actually don't have evidence that they didn't hear anything (and in Aragorn's case we have later confirmation that he actually did: see above).