You're missing a semicolon
sol = Solve[x + y == 2 && x - y == 1, {x, y}]; x = x /. Flatten[sol]; y = y /. Flatten[sol]
Undo the symbol damage with Clear["x"];Clear["y"]; Re-execute and your answers will be OK.
Clear["x"];Clear["y"];
This is how I save it
sol = Solve[x + y == 2 && x - y == 1, {x, y}]; x = x /. Flatten[sol] y = y /. Flatten[sol]
It says is an error
(* Original equation *) sol = Solve[x + y == 2 && x - y == 1, {x, y}] (* Use solution for another function of x and y *) x + 7 y /. Flatten[sol]