What the numbers mean
The squares match. Their surroundings can change how they look.
Both centre squares use exactly the same colour value, #808080. A gray patch can look lighter against a dark surround and darker against a light one. This effect is called simultaneous brightness contrast. Your impression may differ even when the pixels match.
Read the sourcesA colour arrives with neighbours
Researchers study simultaneous brightness contrast by placing equal patches on different surrounds. In a 2020 study, Pawan Sinha and colleagues showed how nearby image information can affect brightness judgments. The effect does not require a secretly changing centre colour. Our squares keep the same value while their surroundings change. [1]
Vision reads relationships
Edward Adelson's review describes how edges, surroundings and the organisation of a scene affect perceived lightness. A visual system has to interpret surfaces under changing illumination. That makes comparing a pair of isolated pixel values a different task from seeing each patch as part of a larger scene. [2]
Put two samples in the same setting
When comparing shades in a design or photograph, it helps to inspect them against the same surround as well as in their intended setting. Those views answer different questions: whether the stored colours match and whether they look similar in context. Here you can change the surrounds while keeping the centre squares fixed. [2]