I’m learning the Shelburne Reel, a Canadian fiddle tune on a PA, after hearing on youtube. I found some music and was happily learning it in the key of A, then going back to the fiddle site a few days later I realized they play it in B flat? A song like the Clarinet polka, that I learned as a kid was in B flat then years later playing with some fiddlers they played it in C? Is a key choice set because of the range of the instrument? Just wondering?
For yourself you can play the tune in any key you like, of course.
For playing with others, yes, a tune is sometimes played in a certain key due to instrument limitations, often instruments other than yours. Remember, "The Shelburne Reel" is a folk tune, and folk regions, even villages, get to playing,in certain keys for a variety of reasons.
One example from Irish trad areas where pipes were plentiful. tunable instruments played in keys friendly to the pipe tunings dominant in the area, as pipes have limited scope chromaticism-wise. In Scotland, scads of tunes are in "A" possibly due to "A" tuned Highland pipes, possibly due to the open-string ease of fiddling in *A.". Same goes for folk music where one-row button melodeons are a big dance instrument.
Folk traditions get customs as to chosen keys and that gets,known as "the" key for that tune. But there can be variance within one traditional genre. Possibly due to pipe or box tunings, in Ireland there were and still are "flat tunings" and "flat sessions.". In a " B" sesh typically you'll have a piper or pipers with "B" tuned pipes, and fiddlers tune down or bring a 2nd fiddle so tuned. "D" tunes will be played in "B," "G" tunes in"E," relative minors the same. There are also "C" sessions, and "Eb" sessions. This derives from old-school regional traditions and iconic vintage recordings that were not in the now- dominant keys of D, G, relative minors. Some great Irish box players still use Eb boxes (2-row bisonoric). "Flat" pipes and seshes have had a bit of a revival in Irish trad though by no means dominant. It is kewler than kewl for a piper to add a B set to their arsenal.
In Ireland bisonoric with its limited key scope is still the dominant box choice though it's loosening up some, bisonoric also dominates in Canada. That affects tune key, though some button box players carry 2 or even 3 accordions.