Given that only papers where you are the first-author will contribute to your dissertation, isn't it a poor use of time to be contributing to the projects of other researchers?
In disciplines* where the PhD thesis consists of a set of published articles, the PhD usually - but not always - must be composed of first-author papers. Yet there are many reasons why it might be beneficial to be involved in other projects as well, so long as one is also making reasonable progress toward the dissertation.
Perhaps the two most important reasons are:
Training. Early on in graduate school, it may be valuable to simply have the experience of going through every stage of a research project from conception to publication, without having to be in charge every step of the way. Often a first of second year student will be involved in a research project on which a more senior student or postdoc is first author.
Portfolio-building. For most students the goal is not merely to finish the dissertation, but to do so in a way that positions the student for future success. It may be preferable to graduate with 3 first-author and 4 mid-author papers instead of 4 first-author papers, for example.
Additional reasons include
- Research assistantship duties. If one is being paid on an RAship, this often contributes substantially to published research that may not be directly relevant to the dissertation.
- Reciprocity. Sometimes students collaborate on a series of papers and alternate first authorships as they go.
- Too good a thing to pass up. Sometimes the lab hits on something so cool that one would be a fool not to be part of it, whatever the authorship position.
- Networking. By establishing collaborations with researchers beyond one's home lab and institution, one builds up one's professional network.
This is only a partial list, of course, but it should provide a sense of some of the reasons that graduate students should not shy away from projects that will lead to mid-author publications.
- Authorship order does not matter in all disciplines. In economics and some subfields of computer science, for example, authorship is alphabetical by convention. Clearly this distinction does not matter in those fields.
[ Edited to include suggestions from the comments and other answers. ]
In addition to Corvus' good answer, it is also worth noting that in many disciplines you can include work from a non-first-author paper in a Ph.D. thesis---you just have to place it in the appropriate context. For example, if your Ph.D. thesis is about a methodology that you have developed, then papers you participate in where you put that methodology to use would be excellent pieces to include in the thesis as part of the validation of its value, even if you are not the first author.
Another good side is networking. By collaborating with colleagues, especially those in other institutions, you end up with a list of collaborators that will be good for your future projects and career. Maybe next time you will end up writing a proposal with one of the co-authors, or maybe someone recognizes you on the job market since you collaborated with them before.