How are lengths of tuples defined if k-tuples are pairs? In the book "Set Theory And Logic" I read the following sentence:

The ordered triple x, y, z, symbolized by (x, y, z), is defined to be the ordered pair ((x, y), z).

The wikipedia page on tuples also mentions the same definition.
To me, this seems absurd, as in that case a 3-tuple is also a 2-tuple, so it wouldn't really make sense anymore to talk about the length of a tuple.
Having just begun, I'm assuming I'm the one not seeing clearly here. Please open my eyes.
 A: Even worse, one may define the ordered pair $(a,b)$ as the set $\{\{a\},\{a,b\}\}$. Note that with this definition (or should I say: construction?), you cannot even say that an ordered pair always has two elements: If $a=b$, we have $(a,a)=\{\{a\},\{a,a\}\}=\{\{a\},\{a\}\}=\{a\}$.
So what? The essence of the notion of ordered pair is that
$$\tag1(a,b)=(c,d)\quad\text{if and only if}\quad a=c\text{ and }b=d,$$and this essence is faithfully represented by the above definition. One could make totally different definitions of ordered pairs that also have this property - so one might ask which of these is really an ordered pair? Well, none of them "is". The only purpose of definitions as above is to make sure that our foundation (here: set theory) manages to ensure us that the strange properties we demand of the notion of ordered pair are not humbug. Once defined, we continue rely solely on the defining properties $(1)$. A question like whether $(a,b)=42$ then does not even make sense (though it might happen that supposedly undefined/non-sensical things like $(0,1)\cup 1=3$ are accidentally true as an unwanted "side-effect" with one possible definition of ordered pair and false with another).
What we really want is to extend our language.
Set theory knows only how to speak about sets, not about ordered pairs.
Can we consistently work with a theory of sets-and-ordered-pairs if we only trust in set theory? Definitions like above are half of the work needed to answer this question affirmatively. For complete satisfaction we have to make sets that we use to represent ordered pairs differ from all "ordinary" sets.
For example, we notice that $\emptyset\notin\{\{a\},\{a,b\}\}$; so if we  replace all other sets $x$ with a "tagged" version $F(x):=\{\emptyset,\{x\}\}$, or rather recursively $F(x):=\{\emptyset,\{\,F(y)\mid y\in x\,\}\}$ and redefine set operations such as $\cup,\cap,\setminus$ and even the $\in$ relation accordingly ($x\in'y:\leftrightarrow \emptyset\in y\land \exists z\colon x\in z\in y$) we reached our goal: We made sets behave as they did before, make ordered pairs behave as they should, can distinguish between pairs and sets, can have pairs as elements of sets, sets as components as pairs, etc.
All this is an awful technicality. Usually, we leave it at a definition of ordered pair as in the first paragraph and henceforth do not use this definition at all - instead, we use only the defining property $(1)$.
You may view this as a semi-formal shorthand for the technical construction loosely described above.
The same goes for triples and $n$-tuples in general: We want $(a,b,c)=(d,e,f)$ iff $a=d$ and $b=e$ and $c=f$, and as we already know that ordered pairs have similar properties, defining $(a,b,c):=((a,b),c)$ has the desired effect. Unfortunately, such a definition is asymmetric and has consequences such as $A\times B\times C=(A\times B)\times C\ne A\times (B\times C)$. We still have a canonical bijection between $(A\times B)\times C$ and $A\times (B\times C)$, but on the left, we "accidentally" have actual equality. The latter follows only from the specific definition of triple, not from the defining property - for example, with $(a,b,c):=(a,(b,c))$ the situation would be different.
So once again, we should perform the technical construction described above to see that the desired extension of our language is viable. Instead, we have a look at the definition once and henceforth use only the defining property.
If we went through all the technicalities, we could ensure that a triple $(a,b,c)$ is actually different from all pairs (including nested pairs like $((a,b),c)$ and $(a,(b,c))$) (as well as from all "ordinary" sets). And in such a situation it would not be problematic that we want the length of $(a,b,c)$ to be $3$ whereas the length of $((a,b),c)$ or $(a,(b,c))$ is $2$.
A: There is more than one way to define a tuple (or, rather, to 'encode a tuple into set theory'). We could use any definition of 3-tuple that satisfies the property $(x_0,x_1,x_2)=(y_0,y_1,y_2)\iff$ $\forall i, x_i=y_i$ (which your definition clearly does)—and similarly for $n$-tuples in general.
This particular definition has the disadvantage that the set corresponding to the 2-tuple $((x,y),z)$ is equal to the set corresponding to the 3-tuple $(x,y,z)$; in some applications, we may want tuples of different lengths to always be unequal. It is this disadvantage that makes defining the length of a tuple to be impossible.
There do exist other ways to encode a tuple into set theory that do not have this disadvantage. For example (using the standard Kuratowski definition $(x,y)=\{\{x\},\{x,y\}\}$ for the 2-tuple) we could define:
\begin{align}
(x,y,z)&:=\{(0,x),(1,y),(2,z)\}\\
(x,y,z,w)&:=\{(0,x),(1,y),(2,z),(3,w)\}\\
\rm etc.
\end{align}
(The 2-tuple would break that pattern, unfortunately, though I suppose we could redefine it to fit.) The length, then, would simply be the number of elements—and no 2-tuple would ever equal a 3-tuple.
In practice, one shouldn't worry about how to encode a mathematical object into set theory in order to use it. (An example: category theory.)
A: You could define the length of a 2-tuple as the length of the first element of the pair plus the length of the second element of the pair. The length of a 1-tuple being defined as 1. (a recursive definition)
So for $((x,y),z)$ the length is 3. Indeed, length of $(x,y)$ (the first element of the pair) is 1 + 1 (length of the first element of the pair $(x,y)$ + length of the second element of the pair $(x,y)$). and the length of $z$ is 1. so 1+1+1 = 3
