There are many types of files that you can edit, but they don’t all have the same rules for what is valid and what is not. So it’s vital that you tell Sublime what kind of file that you think you’re editing so that it knows what to expect. There are many ways to do that but the most common way is to name the file appropriately.
Here’s what your content looks like in my Sublime; note the type of file that it thinks it is:

So first off, the way the content of the file is interpreted is, here, specific to Python. The result is different if Sublime thinks this is supposed to be Ruby code, for example.
Secondarily, the colors you see here may not mimic what you actually see, which would be because we use different color schemes. The syntax definition (here Python) tells Sublime how to interpret the contents of the file, and the color scheme (here Mariana) tells Sublime what color to use for each part of the file.
Seeing Red somewhere is usually an indication of two things:
-
You happen to have a color scheme that someone has created to think parts of your file are supposed to be red (just as here parts of this are green). If that’s the case, then there’s not an issue and changing the color scheme would change the color
-
The syntax definition knows that the content of the file is, based on the rules of the language as it understands them, not correct. In such a case, depending on your color scheme you could see red or some other color as an indication to you that thinks don’t appear correct:

Here the file is visibly broken; there’s a missing '
so the string is not terminated. The syntax definition thinks that is wrong and the color scheme thinks it should display that as this red background color, so it does as a hint to you to that it’s broken.
So, what if the color is displaying like this but the file content doesn’t seem to actually be wrong? If the file type is wrong, the rules being applied are wrong and all bets are off. Or, perhaps the file content is correct but the syntax rules don’t know it or are somehow broken. In that case it’s displaing as wrong but actually isn’t, so everything is fine and in that case you would report the error to the author to fix.
At the end of the day, Sublime is just an editor for text with a bunch of smart bells and whistles, but all it’s doing is editing the text; if the content is correct, regardless of what it looks like, it will still work.
This is the same sort of situation as your car; it’s for taking you from one place to another, but it cares not where you are going or what you’re going to do when you get there. It just transports you along.