Most professors/mentors will let you know when entering the lab if there is the possibility of getting published. However, do not go into a lab with the idea of getting published. There is so much more to research than a publication and it is very important to understand that just having the research experience is a great step into a science career.
Having a proposal lined up or a publication in the works are ways that you can know that a publication is headed your way.
There are 4 ways that you can contribute in order to get authorship on a publication 1) coming up with the project idea 2) contributing substantially to the analysis (generating a coding scheme, running simulations or advanced analyses that no one else in the lab knows how to do, etc.) 3) writing the paper itself 4) contributing important ideasConsistency is key
Prove that you are worthy of getting on a publication and always ask if there is more you can do.
A lot of the labs on campus are learning labs so make sure you invest time into discussing not only with your mentor but also your lab head on similar projects
Do not enter a lab only for the publication and never contribute work. It will show very poorly on your character and reflect badly for future reference.
In the end, pick a project that you enjoy and that you believe will give you what you want at the end.