No, it's not just his age. It's expectation. He has come to expect a treat every time you are out because that is what he is used to. He is starting to tantrum because he has found out that, when he does, it sometimes pays off and he gets the thing he wants.
It is easy to slip into this when they are very little, because they are not asking or pestering, so there seems to be no harm in buying them, something. Unfortunately, the pestering and tantrumming when told 'no' starts at around this age, IME.
If you are happy to carry on buying him little treats, then carry on, but you need to decide if it is under your control, or his. For instance, you could decide to put a cap on it by cost (ie £1 worth of treats a day), which he won't comprehend, but would help you to decide when he's had 'enough', and give you an answer you can stick to: 'No, you can't have that. You've had enough today' (repeat ad infinitum!).
Or maybe control it by telling him he can have one thing a day, no matter what it is, or what else he sees after he's already had the one thing. That would be hard for me to stick to, tbh, as I like to buy 'bargains' when they come up, buy it is an easy one for children to understand, and they can start to understand that they can wait for something better rather than wanting the first thing that comes along.
I think you need to put some sort of control into this, as to say 'yes' one day, and 'no' the next, will be very confusing for Ds, and will lead to pestering as he won't be sure you mean it when you say 'no'.
One trick I use all the time, when DS3 asks if he can have something, is to say 'yes, of course you can, when it's your birthday'. He has invariably forgotten about it within 5 minutes, but if he doesn't forget, I know he really wants the thing, and I can get it for him...for his birthday!
For sweets, I just say 'no' most of the time anyway, so the rare occassions when I buy them sweets, I decide in advance what I will get for them (I bought them all a lolly at the sweetshop yesterday for being good for their eye tests, but I wouldn't ley DS3 have a bag of chocolate buttons- it was a lolly or nothing, otherwise I have 3 DSs all 'choosing', and I end up spending 3x£1.50 instead of 3x15p, as I'd planned! They got a 'choice', as they chose their lolly flavour.