This is not an error. The two squares are really the same color in this optical illusion. It is the lower one with the red dot (the one close to the cylinder) that tricks us. Here’s the explanation.
Our mind adjusts for shadows. If an object is partially in the shade and partially in the sunlight, our mind knows that it is really the same color, even though, to our eyes, the part in the shade looks darker.
In this optical illusion, the square with the red dot close to the cylinder and the four squares surrounding it would be the same color if the surrounding squares were not darkened by the shadow. We know this is confusing, but keep reading. All five squares are behind the cylinder and in its shadow, but only the four surrounding squares have been drawn as darkened by the shadow. The one with the red dot has been left as its original color which is the same color the surrounding squares would be if they were not in the shadow.
If these objects were seen in real life, the square with the red dot close to the cylinder would be significantly darker because it is also in the shadow. But since it has been drawn as its original color, our mind is confused. It assumes it is lighter.
In addition to the trick the shadow plays on our eyes, this illusion is compounded by another assumption our mind makes. This picture appears to be a chess board. Our mind knows that a chess board has alternating dark and light squares and assumes that the square with the red dot in the shadow of the cylinder is one of the lighter ones.
Watch the two animated illustrations below and see what happens when the cylinder moves and none of the squares are in its shadow. In the first one, the color of the square with the red dot which was in the shadow does not change, yet our mind sees it as changing. If you cannot believe it, take a piece of paper with a small hole in it. Position the hole over the square with the red dot and keep it there. You will see that it does not change color. Your eye can now see its true color because it is not seen in relation to the surrounding squares.
You can also see that the color of the square with the red dot in the upper corner appears to lighten as the shadow of the cylinder reaches the surrounding squares. The principal is the same. Our mind assumes that, since the square with the red dot is in the shadow, it should be dark. However, that square is drawn as its original color just as the other one was. When the surrounding squares become dark, the square with the red dot looks light compared to them. Again you can look at that square through the hole in a piece of paper and see that it, in fact, does not change color as the cylinder moves.
Watch the second illustration below. The color of the moving square does not change, although it looks like it does when it reaches the shadow. If you put a piece of paper with a hole in it over the square at the upper corner and over the square in the shadow, you can see that they are the same color.