The set of all finite sequences of members of a countable set is also countable
So maybe it is a good idea to move part of the comments here, since they are relevant to answering the question:
First of all, there is no unique definition of $(a,b,c,d)$, but the standard one is $(a,(b,(c,d)))$. My guess is that depending on the definition it may be impossible that a problem can arise, but using the definition I provided it is possible to have a conflict.
The problem arises in the case some tuple of elements of $A$ is also in $A$. Let for example let's assume that $a,b\in A$ but at the same time $(a,b)\in A$. Furthermore let's assume that $f(a)=1,f(b)=2,f((a,b))=3$. Then the triple $(a,a,b)$ by the standard definition is $(a,(a,b))$. Then it is not clear whether to send $(a,(a,b))$ to $2^2\cdot3^4$ or to $2^2\cdot 3^2\cdot 5^3$.
What Enderton suggests is to pick the least $n$ such that the sequence $P$ lies in $A^n$. Hence in our previous example we should choose to denote $(a,(a,b))$ with $2^2\cdot 3^4$ since this element is in $A^2$ and in $A^3$ but $2<3$.
I have already given this answer elsewhere. Let me repeat this here.
To prove the countability of $\bigcup _{n=1}^\infty A^n$, it suffices give an injective function $\phi$ from this union to $A$. Without loss of generalty take $A$ to be the set of positive integers and for the sake of this proof regard them as written out in base 10, which makes use of the symbols $0, 1,2$ upto $9$. Now let us bring in 3 more symbols namely the comma, the open and then the closed paraentheses which are to be interpreted as the (additional) symbols for the numbers ten, eleven and twelve respectively in base thriteen.
Now the injection $\phi$ takes a typical element such as $(3,8,17)$ and interprets them as an expression base thirteen: $(3,8,17)_{\rm thirteen}$ which when expressed in base ten is $(11\times 13^7) + (3\times 13^6) + (10\times 13^5) + (8\times 13^4) +(10\times 13^3) + (1\times 13^2) + (7\times 13^1) + (12\times 1).$