I am a senior in undergrad who is a physics major applying to PhD programs. I keep on hearing people saying get rec letters from PIs or contact and have a good relationship with PIs.
The abbreviation "P.I." stands for "Principal Investigator" and is routinely used in the United States to denote a "head of the laboratory" or "research group leader" (wikipedia), and serves to refer to active researchers with potential funding for PhD students or post-doctoral researchers.
It is used by various organisms more formally, as the two examples below show.
The United States' National Science Foundation
Quoting the section D.1.g. of their Proposal & Award Policies & Procedures Guide (PAPPG) from January 2017 (which is the latest version to this date):
g. PRINCIPAL INVESTIGATOR/PROJECT DIRECTOR (PI/PD) means the individual(s) designated by the proposer, and approved by NSF, who will be responsible for the scientific or technical direction of the project. NSF does not infer any distinction in scientific stature among multiple PIs, whether referred to as PI or co-PI. If more than one, the first one listed will serve as the contact PI, with whom all communications between NSF program officials and the project relating to the scientific, technical, and budgetary aspects of the project should take place. The PI and any identified co-PIs, however, will be jointly responsible for submission of the requisite project reports. The term "Principal Investigator" generally is used in research projects, while the term "Project Director" generally is used in centers, large facilities, and other projects. For purposes of this Guide, PI/co-PI is interchangeable with PD/co-PD.
The United States' National Institutes of Health
Indeed, the N.I.H. uses the same term for a similar notion. Quoting their glossary,
Program Director/Principal Investigator (PD/PI)
The individual(s) designated by the applicant organization to have the appropriate level of authority and responsibility to direct the project or program to be supported by the award. The applicant organization may designate multiple individuals as program directors/principal investigators (PD/PIs) who share the authority and responsibility for leading and directing the project, intellectually and logistically. When multiple PD/PIs are named, each is responsible and accountable to the applicant organization, or as appropriate, to a collaborating organization for the proper conduct of the project or program including the submission of all required reports. The presence of more than one PD/PI on an application or award diminishes neither the responsibility nor the accountability of any individual PD/PI.
In Australia, "PI" means partner investigator. This is someone who is involved in a grant application but is not eligible for funding. For example, they might be an international collaborator. This is different from the rest of the world.
A grant applicant is a "Chief Investigator" or "CI."
PI stands for Principal Investigator, or Primary Investigator. Essentially the professor that heads a research project. With regards to a project or even lab, there may be one or more PI, in this case they would be called co-PI's (i.e., you may be technically working under more than one professor).
To address the second part of your question, while some people do mention the term PI as it stands towards getting letters of recommendations, ideally you should get letters from professors who can vouch for you best. While it may be ideal to get one from a PI, there could be a professor also affiliated with the project that may not be the PI, but who has worked with you more closely than the PI(s) have.