Another factor is simply sticking around long enough until they have the seniority to be promoted. The motivated people look elsewhere; the mediocre people settle for what they've got and slowly advance inside companies.
It's a mechanism of the Peter Principle.