A shop is a place in which the character may trade his gold for new items, or sell his old items for gold. Each game has a different implementation for the shops; they can be menu based as in Angband or spatially located inside the game, as in NetHack.
Not all roguelikes implement shops, and the rules of trading change from one to another, including charisma bonuses and stealing.
Shops are found randomly and question whether to spend all wealth in recently found store becomes a tactical decision because two levels deeper there may be another with better stuff for sale.
This encourages packratism because hauling many items to sell becomes profitable. When hunger or similar mechanism is too weak or not present it invites to collect and bring contents of whole dungeon to exchange for cash. Offered prices most often are half original value or less.
Merchants will refuse to buy any item. This is easier to balance.
Notable games using this approach: Crawl
Buy identified item to learn
Buying an item will provide allow player to identify same items it on sight. Cheap (or cursed) items are likely to get purchased because this gives information about hazards almost for free.
Buy unidentified item to learn
Purchase is made while knowing only base item type. Bought stuff may be really good, simply mundane, mediocre or even worthless.
Get to know your stuff yourself!
Notable games using this approach: NetHack