Often, through the payment.
People use the same payment methods in the same stores over and over. This data is accumulated by the stores, and sold. if you signed up for a "points card" or some other gimmick to get 2¢ off something, the personal information you used when you signed up is added to the profile.
What you bought in the store is added to your profile (within legal limits in certain jurisdictions).
Some stores have devices that listen to your mobile phone's identifiers (wifi, Bluetooth, etc) and add that to your profile. Now the data profilers know what other stores you shop in. Some stores are experimenting with facial recognition (Walgreens). That gets added to your profile.
If you go to several in a single day, your route between the stores can be guessed. If you go to one or more places (stores, parking garages, streets that pass parking lots) that have sensors that read the NFC chips in your car's tires, then that can be added to your profile.
Now they know everywhere you go, everywhere you shop, everything you buy, how much you buy, how much you spend, your race, your gender, how you dress, what brands are displayed on your clothing, and any visible hair, moles, or tattoos.
That's just off the top of my head.
And people wonder, "Wow. I am a little scruffy. How did Facebook know to show me an ad for a razor?"