When he joined the lab, my work was having a "harvest season", luckily for him. I have been busy writing manuscripts to get the results out. He contributed in generating data for the majority of the analytic work, and as a result he's earned authorship in two recent publications and two pending manuscripts. People in this industry would agree that his case (3-4 authored papers in 9 months) is quite an exception.
There is a widespread misconception among misinformed undergraduates that you work in a lab for a month or two and you get authorship. No, it's a wishful thinking and usually authorship is not that easy to earn.
I give authorship only to someone who made significant contribution. Intellectual contribution is important. I also give authorship to the person who generated critical data that become a part of the figures in final publication. There may be occasions that student's "future" is considered as well, but his/her contribution or involvement should be defensibly significant.
[This general rule excludes data from core facility or outsourced company. Contribution by staff and other collaborators is judged case by case].
Also, timing weighs heavily in your "luck". I used a metaphor of "harvest season". Before harvest, there was a long incubation time for the project to grow and bear fruits. It is especially true in animal-based research I am involved.
In hypothesis-driven medical science, a lot of seeds (hypotheses) die before bearing fruits. They may go unsupported by experiments and turn out to be untrue. Then the whole work can be very hard to publish. Generally, negative or neutral results are a lot harder to publish.
We usually assign students to projects with reasonable expectation of future publication. But publication may not happen in the most convenient time frame for students.
A lab is like a small (tiny) company. As to authorship decision, there are general rules and guidelines in the research field and in the journals. But how it is actually done depends on each PI's management decision. Writing a paper is not a one-month process. It can take years including the incubation and testing steps. What a student thinks it is or it should be can be different from actual and reasonable process, and knowing all these is an important part of learning as well.