I don't really have any advice, but just to let you know that you're not alone. Bess is also 2 1/2, and she can be unpredictable with other dogs. Mostly fine, mostly friendly, or she takes a wide berth around those she's not too sure of, but occasionally she gets snappy or all-out aggressive (even when, like you say, they start off all tails wagging) and I can rarely see why it started or who started it. I think it can be the littlest thing sometimes.
It all started when she was attacked (unprovoked) by a Jack Russell, who she lashed back at and it took me completely by surprise. After that, she barked and growled at almost every dog for a few days, which really worried me, but she eventually calmed down, and after a few friendly meetings was okay again for a while.
All I can say is, all dogs are prone to it, no matter how friendly. It's not always a bad thing if they are simply putting another dog in it's place, and most experienced dog owners are fine about it as they understand. It doesn't mean you have a 'bad' dog or you're a bad owner, it's just in their instinct. I feel reassured by comments here from owners of slightly older dogs who have calmed down. Maybe it's just a learning curve.