I don't know if your brain does this, but mine does and it has really helped me to become concious of it.
Sometimes I'll go to the kitchen looking for a snack when I'm actually
not hungry. 9 times out of 10 what I need is a glass of water, but I
perceive the thirst as something more interesting for my tongue.
Sometimes at my lunch break or on the way home from work when I am stressed and mentally tired, I will want to go buy something. Not "I will want to get x", but just a vague shopping urge coming over me. I suspect that I'm remembering being pleased about getting something I desired and so I start to replicate that experience when what I really want is to have spent time doing whatever I damn well pleased instead of working. What I need is to relax and give myself a sense of accomplishment & completion; there are lots of better (and cost-free) ways to do that than shopping.
Be mindful of your actions and urges. Answer your real needs with the right solution, not a placeholder.