There are a lot of factors involved. In general those who end up in academic research positions tend to be quite talented. I'm not sure what you mean by "top" positions though.
One of the big factors is being lucky enough to have a background in what turns out to be a "hot" field. In the years it takes to do a post doc and a PhD whatever you work on could become obsolete or simply no longer be of much interest to the wider academic community. On the other hand, your area of expertise could also take off - meaning there are more funding opportunities and therefore more job prospects.
Another big factor is creativity, I think. Some people are great at solving exam problems and do exactly what they're told during their graduate work, utlimately producing some good work. But when left to their own devices, particularly when having come through a system that doesn't often reward independent thinking, they don't know what to do. A lot of the more successful scientists I know have several great ideas in their minds at any given time and find that what they really need is the discipline to work on one thing at at time.
Communication and social skills are also huge. This specifically refers to the ability to write a successful grant application, and the ability to network. The more successful scientists I know are the ones at conferences who are able to approach different people and engage in exciting conversations in what appears to be an effortless manner.
Timing plays a big factor. You really don't have much control over this one. Sometimes you can get luck and happen to graduate or complete a post doc when several openings in your field are available. Sometimes there won't be anything for months and you have to figure out how to eat in the meantime. What the general economy is doing can also play a big role in this respect. During the dot com boom, PhDs were getting picked up left right and centre in the commercial sector. During a recession, lots of people will attempt to ride it out as students, creating a competative bolus.