He made an educated guess, based on the information he had.
At this point in time, Ned knows or has worked out that:
- Cersei and Jaime are secretly lovers;
- Bran fell, despite being an excellent climber, on a day when Cersei and Jaime were left in Winterfell while nearly everyone else was out hunting;
- someone, probably a Lannister (he's got the wrong one, but never mind) sent a man to kill Bran.
Clearly somebody wants Bran dead. Why? A child can't pose any threat to the Lannisters or anyone else, except by the information inside his head. What could he know that would be dangerous to the Lannisters? Presumably the same dark secret that got Jon Arryn killed. How could he have found it out? It's a reasonable guess to say he found out on the day he had his near-fatal accident, and found out in the simplest way possible - by seeing Jaime and Cersei together as lovers rather than siblings.
In the book A Game of Thrones, where of course we see a lot more of Ned's internal monologue, his musings with regard to Bran are made more explicit:
Lord Stannis shared the secret Jon Arryn had died for, he was certain of it. The truth he sought might very well be waiting for him on the ancient island fortress of House Targaryen.
And when you have it, what then? Some secrets are safer kept hidden. Some secrets are too dangerous to share, even with those you love and trust. Ned slid the dagger that Catelyn had brought him out of the sheath on his belt. The Imp's knife. Why would the dwarf want Bran dead? To silence him, surely. Another secret, or only a different strand of the same web?
-- A Game of Thrones, chapter "Eddard VIII"
And yet, he knew he could not keep silent. He had a duty to Robert, to the realm, to the shade of Jon Arryn … and to Bran, who surely must have stumbled on some part of the truth. Why else would they have tried to slay him?
-- A Game of Thrones, chapter "Eddard XII"
Although in the book, this part of Ned's conversation with Cersei plays out slightly differently. Instead of stating his suspicions about Bran outright, Ned lets Cersei confirm them:
"My son Bran …"
To her credit, Cersei did not look away. "He saw us. You love your children, do you not?"
-- A Game of Thrones, chapter "Eddard XII"