As said before by @JakeM, colors usually tend to have psychological meanings, but I would have to disagree with his meanings. I think its simple to explain most of the meanings. I'll leave other sources with some other information at the end.
Light Yagami/Kira - Red
His hair and eyes go red. Red is usually associated with Rage, Fierce, but in anime, its also associated with evil intentions. It is extremely common for villains to have red eyes. We may assure Light is the villain here, even though he does not suffer from rage.
L - Blue
His hair and eyes go blue. L is much more obvious than Light if you know the colors meanings. Blue is often associated with wisdom and tranquility, both which describe L very much. Also, in anime, blue hair is a characteristic of an introvert (I guess this one is a key L characteristic).
Matsuda - Yellow
I isn't very common to see Matsuda's hair change color in the anime, however, that is his main moment in the show IIRC. If I'm right, this is the scene he spies the Yotsuba Group. As we see in the chart, yellow is a common color for Hope or Curiosity depending on the tone. We may say that at that specific moment, Matsuda was both as he was searching for information. Also, Matsuda is the young hopeful police officer which is always rooting for the team.
Misa - Light Blue
Honestly, for the time being, the only reason I can see for her to have this color at that specific moment would be to contrast with Light's hair and give a nice image. Also, its worth noticing that whenever they are shown in that dark and colorful forms, usually thinking, Misa may be seen with this light blue hair but with her red Shinigami Eyes. This may also serve to show that while she has her evil Kira ideals such as Light, she also is anything but like him. It works as a double contrast.
On a smaller notice, blue hair may also signify strong will, which is something she has in common with L. We may see that when she does everything possible to get herself near to Kira.
Yotsuba Group - Purple
Purple, by anime, is usually associated to someone cultured or noble, and depending on the tone, in psychology terms may also mean: serious, confident, or concentrating. All of this may apply to them as portrayed by well dressed rich owners of a major group. Also, they are all there to decide whom to kill. I guess this is a good reason to concentrate.
Task Force Members - Green
I honestly couldn't find an image for them. If anyone has it, feel free to add here.
I don't actually recall seeing them green, however, it could make sense because green may relate to how "good" a character is in anime. If we were to go by psychology, we could also relate to how energetic they are, which they really are.
Anime Color Meanings
Anime Hair Colors
Anime Color Emotion Chart: