So Sometimes my code will highlight properly and other times, it gets no colors or anything. What gives! I can't find anything on this meta that has discussed this aspect of this issue.
This is called syntax highlighting as explained over in the SE-meta post :
Before you do anything, are you sure that you've got the correct highlighting turned on? Behind the scenes, Stack Exchanges uses the tags on the question to infer the language you are using. If there's more than one tag that has syntax highlighting, it uses a default and lets Prettify infer what's the best language to use. If you're curious whether a tag has a language hint, any user is capable of checking by visiting that tag's wiki page.
Bolding mine. So, if you're offering a code answer to a question that isn't tagged with the code, you won't get syntax highlighting by default.
You can force a specific syntax by using Prettify language codes. Put this immediately before a code block, and it'll be highlighted as Bash:
<!-- language: bash --> for f in *.mp3; do echo "$f"; done