When it casts a ray, shouldn't it calculate the color and return that? Why would it create incorrectly colored pixels?
Fireflys aren't incorrectly colored. In theory, you need them for a correct rendering result. They are only a representation of a part of your light that is very difficult to sample for the renderer and therefore magnitudes more noisy than everything else.
The problem with them is that they represent a path that a ray is very improbable to travel on. For example, if you have a reflection or a refraction of a very small but strong light source, the probability that any sample will reflect/refract in a way that will hit this small light source is very small. If it hits it, however, the result shows that this should have a big effect on this part of the surface, so it samples a very bright pixel there.
That would be no problem if, for every pixel, a few samples would eventually follow this path and create a bright pixel there, but due to the small probability, only very few ever follow it and these pixels are then far too bright (because they found the way "too early" and are not yet averaged out by the other future samples that would all not find this way). On other pixels, no sample will find the way at all (within the numer of samples you set in your render settings) and are therefore too dark (but only very little too dark, because the actual effect of that light on the surface would not be that big).
So if you would render, for example, 10,000 times as long as you do, the fireflies will eventually become more and weaker and, in the long term, become a normal, noise-free part of your light. It's just impossible to sample for that long.