Ginny told Riddle about Harry’s history.
When Harry is talking to Riddle’s in the Chamber, he explains:
“And why did you want to meet me?” said Harry. Anger was coursing through him, and it was an effort to keep his voice steady.
“Well, you see, Ginny told me all about you, Harry,” said Riddle. “Your whole fascinating history.” His eyes roved over the lightning scar on Harry’s forehead, and their expression grew hungrier. “I knew I must find out more about you, talk to you, meet you if I could. So I decided to show you my famous capture of that great oaf, Hagrid, to gain your trust.”
— Chamber of Secrets, chapter 17 (The Heir of Slytherin)
It’s unlikely the horcruxes and/or soul fragments were at all aware of each other, let alone able to share memories – if they were, Voldemort would surely have been aware that they were being destroyed long before he actually did.
It’s also worth noting that Riddle’s knowledge of past events is incomplete. He’s clearly received a second-hand record of events; this isn’t the description of somebody who was there:
“No one knows why you lost your powers when you attacked me,” said Harry abruptly. “I don’t know myself. But I know why you couldn’t kill me. Because my mother died to save me. My common Muggle-born mother,” he added, shaking with suppressed rage. […]
Riddle’s face contorted. Then he forced it into an awful smile.
“So. Your mother died to save you. Yes, that’s a powerful counter-charm. I can see now – there is nothing special about you, after all. I wondered, you see. […]”
— Chamber of Secrets, chapter 17 (The Heir of Slytherin)
When Harry meets Voldemort in Goblet of Fire, he’s worked out that it was Lily’s sacrifice which saved him. I think it’s very likely he’d worked this out before Chamber of Secrets – he had years to think about it – but the diary!Riddle knows nothing about it.