I can understand credit as a natural extension of “running a tab” at a hotel or restaurant—you order now, and settle your account later, for various definitions of “later.” But why would a retailer be interested in offering private/internal credit that they had to manage and settle? Sounds negative-ROI to me.
People would set up accounts at their local stores so all their common daily and weekly errands could be done without cash. Then once a month (after payday) they would take cash around to all the local stores paying their accounts. (Or write a check, I guess)
Stores supported this because it was a form of lock-in, and because it reduced friction. Faster than exchanging cash too, or writing a check.
When working correctly (the customer comes in and pays without prompting) it's super low effort. Especially for stores with only one location and checkout counter. Only really costs time and money when a customer requires chasing up.
You're probably coming from the opposite frame, that requiring cash up front for all transactions was the norm. It wasn't. We've been extending credit and taking on debts for millennia. It's just how money works.
It seems to me that this store credit thing has been very much a US thing, and it probably is the reason why credit-based electronic payment systems took over the US while at the same time debit-based systems accomplishing the exact same goal became dominant in many European countries.
Funny thing: when it comes to gasoline, the roles are reversed. In the US, you get no gas if you don't first go into that store and prepay or provide a credit card that guarantees a payment. In most of Europe, you just drive up to the gas pump and fill up, and then you go into that little store in order to pay.