OK, it's been a while since I saw TPM but I'm pretty sure that's not what Yoda says. IIRC the line is: "Always two there are. No more, no less. A master and an apprentice."
As for how Yoda knew...hell if I know. Maybe the Jedi have had more encounters with the Sith over the preceding millennium than is generally known. A secret known only to the grand master and a select few on the council perhaps? Lucas has always been a bit vague and inconsistent regarding the history of the Jedi, Sith & the Republic.
Either way I'm sure the EU will find some way to retcon an explanation in sooner or later.