@w@ what a mess.
Xion is a Replica crafted from Memories. During his KH1 Final-Mix battle with Sora, Xemnas snatched some Memories and thus established a link between Sora and Xion.
This happened a week after Roxas joined the Org, making Xion his "underclassman".
Namine delinked all of Sora's Memories when he went to sleep in the pod, and then they began leaking out to Roxas, and from him into Xion. No abundant copy of Memories occured, simply transfer.
What happened in Snarl of Memories (being the Riku-Zexion flashback scene) is that Xion and Roxas, while being on DI and in close proximity to Riku, managed, for some unexplained reason, to see Riku's Memories. Makes sense then that they'd have a mind-trip as Roxas in particular and Xion for the most part are Sora-oriented, but suddenly they have someone else's Memories bouncing around in them.
That was why they transformed into each other, into Riku, and then into Sora - all people Memories of whom they'd have access to.
Theories are abound, and my personal pet is that Xion is also at least a partial Replica of Riku (would certainly explain why Repliku was an incomplete Replica despite being made at the same time as Xion, it seems) that just got more Sora connections due to circumstances.
Hope I helped clear things up a bit.