When U(x) is maximum along x-axis, then dU/dx=0
But it did not imply dU/dy=0;

There is no maximum for U in y direction. U(y)=mgy . It is a line with slope mg.