Why color illusions happen
Your brain doesn't measure color like a camera: it compares it with what's around it, corrects for light and shadow, and fills in what's missing. Most of the time that helps you see the world well, but these images expose it.
Does it matter for design?
Yes. The same color can look lighter, darker or a different hue depending on the background. That's why you should test a palette together rather than each color on its own.