I mean english isn’t my first language, but I do use it quite a bit and the general rule of thumb with “A” and “An” is consonants for “A” and Vowels for “An”
When you speak the S is pronounced as “ess” so it starts with a vowel. The general rule follows pronounciation. So “a S5” as in “a ess five” sounds wrong. Thus if you spoke that it would be “an S5”, and that is then how it is also written.