It is using default/guessed highlighting when you apply the bash tag, because the bash tag does not have a language set for it. In this case, your code is getting highlighted as SQL when you use the tag instead. - @animuson
Just a quick heads up, NEVER use that to highlight syntax, it is long and annoying :P. I recommend:
(Ignore the brackets, they are for formatting purposes)
So basically right after your triple back apostrophe, you put
lang-[lang]. Make sure it is one word though. Short abbreviations of the language name is allowed, but do check if it works in the first place as some don't work, but always better to not use abbreviations I guess. E.g.
lang-py or lang-python
Both of the above provide the same syntax highlighting.
Check more on What is syntax highlighting and how does it work?
You can also put a version number after the langague name if you want (although the syntax will choose the latest one anyways and I have observed it makes no changes to syntax for some reason).