Two colors, side by side, interact with each other and change our perception accordingly. The effect is known as ″simultaneous contrast″. Since we rarely see colors in isolation, simultaneous contrast affects our sense of the color that we see. The real colors are not altered; only our perception of them changes.
Here is an example of how the same "grey" appears different on different background because of simultaneous contrast.