It's a consequence of our capitalist society, of how we're not allowed to just exist in most places without buying or consuming something. About the only places we have left are sidewalks, public parks, libraries, maybe a large mall. Anywhere else and you can potentially be asked to leave if you're not seen "doing" something or at least looking like you're going to buy something after awhile. If the staff don't care, you can "get away with it" (that is, get away with just existing), but more often than not you may be asked to leave. I'd try to test the theory out by just standing around for a few hours, but who actually has that kind of time?
It's more a consequence of place and purpose. If you're in a place and don't use it for the usual purpose, then your motives will be questioned. A store is place to get items. Even if there was no exchange of money, but you went into the store and walked out without anything, it would appear odd.
Go brush your teeth at a library, stand on a sidewalk for a long period of time, ride a bike through a mall. All these things don't cost money but they are still weird.
And for me the feeling is inversely proportional to the time spent there.
I'm looking for something very specific, they don't have it, I leave. But man, does it seem I just went in real quick to steal something as fast as possible.
I won't let myself leave a local book store without buying anything, hence I only visit when I'm out of reading material.
Probably plays back into when I helped watch my father's and mother's trade show tables respectively. My father would sell sports cards back in the 90s and he was lucky to have one paying customer all day at an event we had spent all morning setting up for.
My mother used to paint whimsical designs on chunks of wood (toll painting) and set up a table of her painted wood art various church sales. I saw the hours my mom had spent tracing and painting those dumb little seasonal characters, only to see these rich bitches saunter by her table, turn her work over, say "That's cute!", And walk on.
To this day I will not walk into an antique store or junk shop or book store without at least ten bucks to burn. It feels gross to take up a shopkeeps time and space without buying something.
My wife always feels guilty about leaving a small shop without buying anything and will say stuff like "We'll be back!". I have to remind her we're under no obligation to buy anything and you shouldn't feel guilty about it.