Equivalent formulations leading to different objective values

I’m trying to use CVX to solve a simple SDP feasibility problem. The mathematical problem is the SDP relaxation of sensor localization, i.e. [a_i; -1][a_i;-1]^T\cdot [I, x; x^T, y]=d_i^2, [I,x; x^T,y]\succeq 0. We take i=1,2,3, and a_1=[1;0], a_2=[-1;0],a_3=[0;2], and d_i=\|x_0-a_i\|_2,
where x_0 is generated randomly. I tried the above formulation along with an equivalent one with
[a_i; -1][a_i;-1]^T\cdot [I, x; x^T, y]=d_i^2 replaced by [a_i;-1]^T [I, x; x^T, y][a_i;-1]=d_i^2. But the first version never outputs something reasonable, while the second always outputs x\approx x_0. Below are the two versions:

  1. Version One:
    a = [1, -1, 0; 0, 0, 2];
    lambda = randn(3, 1); lambda = lambda / sum(lambda);
    xtrue = a * lambda;
    d = pdist2(xtrue’, a’);
    I = eye(2, 2);
    cvx_begin %quiet
    variable Z(3, 3) semidefinite;
    variables x(2) y;
    minimize(0);
    subject to
    Z == [I, x; x’, y];
    for i = 1 : 3
    dot([a(:, i); -1] * [a(:, i)’, -1], Z) == d(i)^2;
    end
    cvx_end
    norm(x - xtrue)

  2. Version Two:
    a = [1, -1, 0; 0, 0, 2];
    lambda = randn(3, 1); lambda = lambda / sum(lambda);
    xtrue = a * lambda;
    d = pdist2(xtrue’, a’);
    I = eye(2, 2);
    cvx_begin %quiet
    variable Z(3, 3) semidefinite;
    variables x(2) y;
    minimize(0);
    subject to
    Z == [I, x; x’, y];
    for i = 1 : 3
    [a(:, i)’, -1] * Z * [a(:, i); -1] == d(i)^2;
    end
    cvx_end
    norm(x - xtrue)

Any idea on what’s behind this? Many thanks!