Companies have a registry of their shareholders. Anyone with at least one share registered in their name is a shareholder of record.
However, the vast majority of people who consider themselves "shareholders" aren't actually registered owners of a stock. Instead, almost all public stock in the US is held "in street name." That means that the stock is formally held in the name of a brokerage. What an individual has is "beneficial ownership:" the brokerage passes dividends on to the beneficial owner, will vote how the beneficial owner tells it to vote, and requires agreement from the beneficial owner before it can sell the stock. To make stuff even more complicated, the broker itself generally holds the stock in street name. Almost all public stock in the US is really owned by the Depository Trust Corporation in the name of Cede and Company (a general partnership of a few DTC officers).
The reason public stock is mostly held in street name is efficiency. Transferring the legal owner of a piece of stock is a nontrivial process; until recently, it involved physically shipping stock certificates to the new owner. Even now that stock ownership can typically be transferred electronically, it's much easier to tell Cede & Co. "the new beneficial owner is this person." Because beneficial ownership is just a contract, you can skip all the formalities of updating the company's official register of shareholders.