Since f is analytic, and f(0) = 0, it has a power series with no constant term. Divide by z, and the power series shifts. The result remains analytic inside the unit disk.
Let g = f/z. The absolute value of g is bounded by 1/r for any radius r < 1. This approaches 1 as r approaches 1. Suppose |g(z)| exceeds 1. Select r so that 1/r lies between 1 and |g(z)|. Now |g| is a continuous function on the closed disk of radius r, and it attains its maximum somewhere inside the disk of radius r. This defines a local maximum on an analytic function. Assuming g is nonconstant, we have reached a contradiction. Therefore |g(z)| ≤ 1, and |f(z)| ≤ |z|.
If g is constant then f = cz for some c. With f bounded by 1, c is bounded by 1. Once again |f(z)| ≤ |z|.
If |f(z)| = |z|, then |g| is constant, and g is constant, and f = cz. To attain equality, |c| has to equal 1. Thus f is a rotation of the unit disk. This is the only analytic function that preserves absolute value.