Why do variables that have been constrained greater than or equal to 0 have negative values?

With regards to z taking negative values, you can add the constraint z>=1e-6 and check if that solves the problem. Kindly check this answer by @Mark_L_Stone here How do I limit the optimization variable to be non-negative when I'm using the sedumi solver.