Why would a top department hire a less experienced researcher for a tenure-track position?
Candidate A might have a research agenda (either based on her dissertation, or on her formulated research plan) that fits better with the research agendas of other people in the hiring department, or with strategic priorities of the department or even other departments at the university.
Candidate A might already have collaborated with members of the hiring department, maybe in writing grant proposals.
Candidate A might be cheaper, in terms of salary, lab space, funding or anything else the hiring department may need to cough up.
The hiring department may be afraid that the "superstar" candidate B has so many more attractive offers that she would not accept an offer at this department at all, so they would rather not expend the time to go through the entire process with her.
Candidate A might just have better contacts, because her Ph.D. advisor is big friends with the dean of the hiring department, or (less sinister) the dean has met candidate A at a conference and been very impressed with her presentation.


My advice: do a little research on the people and the priorities at your target department, and emphasize unobtrusively in your cover letter and research plan how you could collaborate and find synergies. And tap your network. Good luck!