I think the idea is that, at least during CoM, Sora never really actually lost his memories of Riku because he had to remember Repliku when he interacted with him, while he was made to forget Kairi and everyone he interacted with in the memory worlds. So since he never lost those memories, they weren't the memories swirling around Roxas and Xion (I don't think Riku is in any of their flashbacks, it's always either Sora and Kairi or Sora alone), meaning Riku never forgot him.
Castle Oblivion doesn't actually take your memories away as far as I can tell (as the Org members never have any issues beyond the place being hard to traverse), it was only Naminé messing with SDG under Marluxia's orders, and everyone else getting affected by it because chains of memories. Which makes Eraqus talking about people being 'lost to oblivion' kinda weird, but I guess it was just hard to find your way out when you got in.