Q: Why did both Frodo and Aragorn keep Gollum a secret for seemingly no reason? After the Fellowship had left Elf Paradise and was boating down the long river, Sam notices what turns out to be Gollum following them.
Sam tells this to Frodo in the camp, which has no guard, and Frodo then reveals that he agrees that it must be Gollum and that he had suspected this. But instead of telling the rest of the party, or even just Aragorn personally, Frodo decides that Sam is to take only half the watch and then Frodo will take over from that, specifically mentioning that "there is no need" to tell the rest of the Company.
When Sam wakes Frodo up, Frodo soon notices Gollum, and draws his sword, ready for a fight. Aragorn wakes up for some reason, and then reveals that he has known about Gollum following them all along, and even tried to catch him several times.
Why on Earth would Frodo risk not just his own life, but the fate of the world, by only keeping a single hobbit at a time to guard the Ring against a deranged lunatic who is obsessed with the Ring and is very accustomed to murdering people and creatures with his bare hands, and who could extremely easily murder Frodo and take back the Ring, becoming invisible and impossible for them to ever regain?
And perhaps even more importantly: why did Aragorn keep this critical information to himself, and, at least knowing about this himself, neither set any guard for the Company, nor insist on staying awake himself? He just goes to sleep with all of the rest and pretend as if they don't have this insane murderer lurking around?
Frankly, this behaviour by Aragorn is extremely careless, is it not? He is supposed to be the wise leader of the Company now that Gandalf is gone, but he puts them all at risk for a number of days whereas Frodo "only" doesn't tell the rest of the party immediately, but in Frodo's defence, at least he does have some kind of guard.

A: A plausible answer -- Tolkien does not give a reason -- is that Aragorn hoped to capture Gollum and needed to not scare him off.  Had he told the Company, "Gollum -- you know, the one who hates Baggins forever and wants the Ring back -- is following us.  Please don't act any different now that you know this, as I want him to get close enough that I can catch him. So don't keep looking over your shoulders, don't jump at sudden noises, and be sure to fall sound asleep at night, so he's tempted to sneak into our camp and throttle you," what would have happened?  Aragorn trusted to himself and kept silent.
In Frodo's case, he's a hobbit who likes his comforts and, while he's had a rough few months, is hardly a savvy leader in dangerous situations. ('Well, you do want looking after and no mistake: your party might be on a holiday!' as Butterbur said about Merry while they were at Bree.) Frodo misjudged.

A: Adding to the other answer, since there can only be speculation on this answer :
For Aragorn, another plausible reason may be that he felt confident in his own capabilities to defend Frodo from Gollum (an enemy that he already knows well), including during his sleep : see how we wakes when Sam has an alert. And maybe he thinks Gollum won't try anything against that big of a fellowship (that contains Aragorn, who caught him once, and an Elf, which he does not like), even asleep.
For Frodo, there might actually already be some part of pity towards Gollum : he does not want another member from the company to kill him unnecessarily, does not know how Boromir or the others would react against him, and thinks that a hobbit's watch is enough to defend against him.
