I'm not doubting that Gollum was corrupted by the ring and that he wanted it completely for himself. However, In the movie "The Two Towers", when Frodo and Sam arrive at the black gate, Gollum stops them from entering after the army. He eventually says something along the lines of "He wants it, always seeking, and the precious wants to go back to him."(I don't remember the exact line). So clearly, Gollum understands the danger reuniting Sauron and the ring would pose. So my question is, in Gollum's own narcissistic way, was he actively trying to keep the ring to himself so that it never fell back into the hands of Sauron? After all, he didn't learn what Frodo was actually trying to do until much later in their journey.
Yes and no.
This sequence is in the books too, in the Two Towers chapter The Black Gate is Closed, and here Smeagol/Gollum's words are stronger:
'No, no, master!' wailed Gollum; pawing at him, and seeming in great distress. 'No use that way! No use! Don't take the Precious to Him! He'll eat us all, if He gets it, eat all the world.'
It's notable that, while Gollum claims a motive of wanting to prevent danger to the world, this is also exactly the point at which he suggests the alternative route through Cirith Ungol.
Later in the same passage Gollum expands on his motive a little more:
So Smeagol is very afraid. He does not want to lose nice master. And he promised, master made him promise, to save the Precious. But master is going to take it to Him, straight to the Black Hand, if master will go this way. So Smeagol must save them both...
(Note that when Gollum says "Precious" with an upper-case "P" he's referring to the Ring, with a lower-case "p" to himself.)
From this it's clear: Gollum knows the risk of Sauron regaining the Ring and very much does not want that to happen. As to the reason why: so that he can have it instead, or for a more altruistic motive, we don't really have sufficient information at this point in the narrative (although it's also clear that at a later point it was so he could have it, but this reason could have changed from the earlier time).
I don't think so. My impression of Gollum is he is very childlike in his mind. I felt that he just wanted to keep the ring to himself because of a childish possessiveness, rather than some innate knowledge to keep the ring from Sauron. However you do bring up a good point. Unfortunately the only way we would really know is to ask Tolkien, but that isn't going to happen.
By the way, I'm going from knowledge of the books. I've never seen the films, nor do I desire to.