First of all, unequivocally, size matters! It has everything to do with the circumference of the fully inflated bag under your arm. A too-small or too-large pipe bag will compromise comfort, control, and performance.
Just for fun, take a regular breath and blow it into a balloon. That’s the amount of air you’re replacing each time you breath into the bag. I’ll bet you thought it was a lot more than that, eh? The size of the bag matters not, other than as a matter of comfort and control.
Most recommend bag size according to height and “generally speaking” I think it’s probably not a bad place to start. You should also take into consideration your chest and torso and the length of your arms. If you’re stout with short arms, you may find that a medium is too large. Also, the dimension of bags from maker to maker can differ. You should research these things before making a purchase. If possible, have a tune on someone else’s bagpipe to gauge comfort and control.
I’ve seen some pipers where the drones are forever falling off their shoulder. If this is you, try a slightly larger bag. Check your posture and see if this helps.
90% of the pipers out there will find that either a medium or small size feels best. Some may prefer an “extended” version, which is just a tad longer than “regular”. I honestly don’t think this has an impact on anything, other than perhaps it takes an additional breath to initially inflate the bag. It may provide a bit more room for moisture management systems as well. Extra-small is also available by many makers. Just as an aside, Bill Livingstone (Gold Medalist and ex-PM of the World Champion 78th Fraser Highlanders of Toronto, had a bag specially made which was smaller than the “small” size bag. He found it more comfortable. While working with various bands, I’ve swapped people into “The Livingstone” size bag with very good results.