How important is primary authorship in judging someone's research contributions? I wanted to know how the research profile of a doctoral student or a post-doc is usually judged in academia. In the list of peer-reviewed conference or journal publications, how crucial is the position in the authors list, to judge the research calibre.

I am aware that being the first (primary) author is most important. As an example, consider a case where a candidate has 4-5 publications. In all these publications he/she is neither the primary author nor the supervisor of that project. On the other hand, assume he/she has 2 highly ranked publications as the first author. Which of these two cases can be used as a comparative study of the candidate's research contribution.

I see these days a kind of rat-race for papers, where each publication has more than 4 authors. Is the "number of papers" parameter lone enough? 
Agreeing that working on multiple projects is important, should the focus be more on publishing one's own work rather than collaborating on multiple papers where the contribution is not significant.
Your focus needs to be on accomplishing significant work, and then receiving appropriate credit for that work.  Number of papers is often a reflection of that, but is not, ultimately, the metric on which you will be judged by anybody who is actually thinking of hiring you.  More distant reviewers of various sorts (e.g., for a grant or a tenure case) are more likely to apply publication-based metrics out of a lack of knowledge or imagination.  Anybody who is considering hiring you, however, should be less interested in what your rank order in authorship is and more interested in what you have accomplished (which is partially reflected by author order).

For example, in your question about comparing a candidate with middle authorships vs. first authorships, I would want to know what, exactly, either candidate had done.  Did the first author candidate actually conceive the work and do most of the writing, or were they just acting as a lab tech on behalf of the more senior authors?  Was the middle-author candidate just along for the ride, or was it a complicated project where their contribution was critical, but others happened to be more critical.  

Thus, in a statement of purpose or other self-presentation, I look for a candidate to be saying, "I accomplished all of these things (as reflected by these publications)", rather than simply "I have all of these publications."