I look at what bases I have covered, what I don't have covered, and what's in the most urgent need of getting covered. Then I come up with a plan to take care of the "hole" in my collection and I stick to it. I don't buy what's not part of the plan no matter how cool it is, because I don't "need" it. I buy only what I need and I try to get it right the first time when I buy.
Case in point - I passed up a great price on a lightly used, pre-safety S&W J-Frame .38 today. I took a look at it, checked it for function and timing, and thought about it hard. I liked it. I wanted it. It would be a great carry gun. But it wouldn't be a better carry gun than what I have. What I have works fine. When I get another CCW gun, it's going to be a small gun, smaller than a J-frame, and something I can carry when I can't carry anything else. That's the only other CCW gun I'd need right now, so that's the only CCW gun I'd buy. Even at that, I don't need it yet.
I put the J-frame back in the case and walked away. I also have soft spot for old-timey sixguns. I want an open-top Colt repro and a 1875 Remington clone... but practical, they are not. Some day I will own one of each... but today I can do without.
Teach yourself to think this way and it will help a lot.
I also save money on accessories and ammo when I can...
I figure out what I need, set money aside, and watch for a deal. I recently bought some speedloaders from Midway for about 30% less than they usually go for. I needed a few more and bought them when they were on sale - when it was smart to buy them. Lately I've also been hitting up the local shop to buy Speer 148 grain .38 caliber wadcutters when it's remotely possible. They're cheap and shoot great, so I buy as many as I can while I can afford them and they're available. It's not like I can have too many of them because they are going to get used eventually.
Another thing - I have an idea of the value of the guns I feel I need and I don't overpay. Someone will sell me what I need at the price I can pay if I look long enough. I shop used when I can and have a grasp of what I'm doing, but it's a risk. Still, there's a risk anymore even with a new gun. Shopping used isn't that much more risky and my preferred shops have good customer service and don't give me BS about making a defective used gun right. And make your face seen at the local shop. You don't have to buy everything there. I get a lot online because it's cheaper, but I also do get stuff locally. They know me on a first name basis, they recognize me when I come in and we talk guns, and at one of them I sometimes get a discount for my loyalty. It makes a difference to me and they appreciate my business... because they also know that I can get stuff cheaper online, they know that I know this, and I come in and buy from them anyhow.
Buy in bulk. Buy a thousand rounds of ammo or a thousand primers at a time if you can. Winchester Small Pistol primers are $3.99 per 100 locally but they are $31.99 per thousand. It's a no-brainer, and I'm going to use primers when I reload anyhow, so why not get them for the best price?
Watch for deals. I saw a Russian Makarov once for $125. I didn't need it and told the manager of the LGS it would be worth twice that after looking it over. He's a personal friend and he knew that. He didn't change the price. It was still there the next day so I bought it. I knew that at the price I had paid, I simply couldn't lose. It served its purpose, then helped me finance another gun.
And FWIW, it's taken me awhile to figure out how to be smart about this stuff. I'm actually still getting smart about it. But as you say, what I want would require a lot more money than what I can spend. With that in mind, I can't afford to waste one penny.