From what i know (a lot of research and a brother with SM) its often sudden onset. Like you move school or experience something traumatic and then find yourself unable to speak. It’s an extreme response to anxiety- this can be social anxiety but can be others like separation anxiety or school phobia. It’s not just worry about speaking, it’s a physical inability to speak. People with SM will tense up completely on their way to school or a social event and exhibit other symptoms like nausea. Obviously though it is different for everyone!
With your situation, my advice would be to talk to someone about why you are worried and see if you can sort that out.