These squares are actually the same exact color. Hold your finger over the boundary between the two shapes and see them change.
The Cornsweet illusion exploits the brain's lateral inhibition, which creates more contrast between the two objects when they have different colored edges.