well, it's rather the opposite - AI is vulnerable to these kinds of tricks, you can inject some patterns into images to make the AI perceive the image in a completely different way, humans are in fact much less susceptible to this, at least for now
So how does ai exactly knows which color is the picture... I always thought that by analysing the binary it is possible to recognize previous learned sequences for predetermined colors and as such answer the question... In this example there's no sequence for red for example...
AI basically recognizes patterns and returns a likely output based on the patterns it found. It doesn't check "this is a red pixel, so this is red", it checks "this pattern is usually red, so this is red".