I usually buy with a specific project in mind, though I might buy more fabric than I need if it's one I particularly like and can imagine myself using it in other projects in the future.
Occasionally, when I'm just browsing, I will see something that inspires me, and will buy it on the spur of the moment. That happened last week - I saw a pack of fat quarters in Hobbycraft in on-trend colours that I really liked, and I instantly wanted to use them in some cathedral windows cushions that I've fancied making for some time. Unfortunately, the colours wouldn't suit the present colour scheme in our lounge, so I've also been out and bought some new paint and will have to redecorate the lounge to match. Talk about making work for myself!
.
I now try to avoid buying fabric unless I have a project in mind, having already accumulated several yards of fabric bought at the local market and that I haven't yet found a use for.