I think that Legolas was told to meet the young ranger, Aragorn, and then return to Woodland Realm. Then few years later Aragorn captured the creature, Gollum and brought him to the Mirkwood as a prisoner. Then Aragorn returned back to North. After Gollum escaped from Mirkwood, Legolas came to Rivendell to inform about it to Lord Elrond. So then he accidentally participated the council there and became one of the Fellowship of the Ring.
This is just what I think...That's all ...