For ideal requirements for authorship, see:
ICMJE | Recommendations | Defining the Role of Authors and Contributors
The relevant bits:
"The ICMJE recommends that authorship be based on the following 4 criteria:
- Substantial contributions to the conception or design of the work; or the acquisition, analysis, or interpretation of data for the work; AND
- Drafting the work or revising it critically for important intellectual content; AND
- Final approval of the version to be published; AND
- Agreement to be accountable for all aspects of the work in ensuring that questions related to the accuracy or integrity of any part of the work are appropriately investigated and resolved."
"Those who do not meet all four criteria should be acknowledged"
In reality, all authors almost never meet all the criteria listed above. PIs may tack on colleagues who only advised for 15 minutes. For undergrads, it largely depends on your PI and your supervisor. You can only increase your chances by actively participating in the research (i.e. intellectual contribution) which typically involves designing experiments to challenge a model/hypothesis. Students are not likely involved with manuscript preparation unless they are first or second author. 3rd and 4th points are always a given when submitting a manuscript for publication.
For undergrads, I would boil down authorship to:
(1) Do you know your publishable contributions to the manuscript inside and out? (What)
(2) Can you describe the rationale for each experiment you conducted? (Why)
(3) Did you have input in the design of experiments (which goes beyond optimizing antibody concentrations for Western blots for example)? Or did you merely follow instructions? (How)
(4) Did you interpret data you collected, as in how do these results support or refute your model? (What it means)
In my experience, undergrads do not have a good enough grasp of the project to warrant authorship. If you can't understand the project, there's no way you were able to design the project. Of course, some PIs will be nice enough to just tack you on, so YMMV, but this all starts with communication with your PI/supervisor. And as always, be polite when discussing potential authorship and have a realistic understanding of your contributions. There's nothing more annoying for a seasoned researcher to hear than a newbie asking for publication just because they could follow orders.