You don't need to select the weapon group as well. Only the weapon.
I've always selected the weapon group with the weapon itself. The only times I've bought the wrong ammo was out of impatience without proper selection.
It does not matter at all which weapon group you select. You will still buy the wrong*
ammo, if you press quick-buy too fast. Selecting a different weapon group has no influence whatsoever.* you will always buy ammo for the first weapon in your weapon list that requires ammo when this issue occurs, no matter what. If that happens to be the ammo you want to buy free tons for, then it's not the "wrong" ammo of course