It seems to be intentional, everytime you buy an item from an NPC the old you spend goes onto them.
Hell, an npc who runs a shop has their entire shop inventory on them too, so its entirely possible to steal literally every item from a store for free, or just buy the ones you want and steal your gold back never losing any at all.
Seems really dumb that you can get every shop item in the game for free with zero repercussions.