The Concept of Isometry under Riemannian Metric's Context While reading the book Modern Geometry — Methods and Applications
Part I, I have a problem reconciling the definition of isometries with the usual version (an isometry preserves the distance between two points). Quoted from the book, an isometry (or a motion of the given metric) is a transformation preserving the Riemannian metric (Def. 4.1.1., page 24). That is, 

$x^i = x^i(z^1, \dots, z^n)$ is called an isometry if $g'_{ij}(z^1, \dots, z^n) = g_{ij}(x^1(z), \dots, x^n(z))$,

where the $g_{ij}$ and $g'_{ij}$ are Riemannian metrics of corresponding coordinates systems.
My problem is, how is the concept of distance connected with that of $g_{ij}$? Assuming that the distance between $x_1 = (x_1^1, \dots, x_1^n)$ and $x_2 = (x_2^1, \dots, x_2^n)$ is defined as

$d(x_1, x_2) = \sqrt{\left< \xi, \xi \right>} = \sqrt{\sum_{i, j} g_{ij}(x_1) \xi^i \xi^j}$,

where $\xi$ is the vector originating at $x_1$ and terminating at $x_2$. Let $z_1, z_2$ be points corresponding to $x_1, x_2$ under an arbitrarily chosen transformation, respectively, and let $\eta = \vec{z_1z_2}$. Then, by the definitions of vector and inner product in this book,

$d(z_1, z_2) = \sqrt{\left< \eta, \eta \right>} = \sqrt{g'_{ij}(z_1) \eta^i \eta^j} = \sqrt{ \left[\frac{\partial x^k}{\partial z^i} g_{kl}\frac{\partial x^l}{\partial z^j}\right]_{z = z_1} \eta^i \eta^j} = \sqrt{g_{ij}(x_1) \xi^i \xi^j} = d(x_1, x_2)$.

This suggests that every transformation is an isometry, which is obviously absurd. Thus, either my assumed definition of distance is false or I have misunderstood the definitions of vectors and inner products. Can anyone point out my fallacy?
*This question is coming out when I am tackling with an exercise stating that every isometry of Euclidean n-space is affine, for which I have known a proof like in page 7~8 of this document. Unfortunately, I am unable to "translate" it into the context of Riemannian metric due to my shortage in concepts of distance.

The distance you have written down ($\sqrt{g_{ij}(x)\xi^i \xi^j}$)
is the distance in the tangent space at $x$, which has a Euclidean structure defined by the metric tensor $g_{ij}$.
The distance in the ambient Riemannian manifold is defined in a more complicated way as the infimum of length of curves joining to given points $x,y$:
$$d(x,y) = \inf \{\ell(\gamma): \gamma \text{ a piecewise $C^1$ curve joining  } x,y\}$$ 
The metric enters via the length functional:
$$ \ell(\gamma) = \int_0^1 \sqrt{g_{ij}\circ \gamma (\gamma^\prime)^i(\gamma^\prime)^j}$$
So the question is which (differentiable) maps $\phi$ preserves this distance function, and a necessary condition is, obviously, that the differential of $\phi$ preserves the metric tensor, which means it is an isometry between tangent spaces.
