In A Course in Universal Algebra in definition 10.1 terms are introduced.
What puzzles me is the statement about arity:
"A term $p$ is $n$-ary if the number of variables appearing explicitly in $p$ is $\leq n$."
Does that mean that the arity of a term $p$ is at most limited but not defined, and can take several values?
If e.g. $p$ is a variable then can every integer $\geq1$ be put forward as arity of $p$?
This seems to be confirmed in the definition 10.2 (also troubling me) where for term $p(x_1,\dots,x_n):=x_i\in X$ a mapping $p^{\mathbf A}:A^n\to A$ is prescribed by $(a_1,\dots,a_n)\mapsto a_i$.
I really do not understand this definition.
If I just start with term $x$ wich is a variable then according to def. 10.2 $x^{\mathbf A}$ must be some function $A^n\to A$. But if so, then what is $n$ (can it take several values?) and how is the function prescribed?
I think you've got it (ugly as it seems). The point is that a term on its own isn't a "complete" object, and so it doesn't have a unique arity.
Certainly there's no problem talking about the arity of a map from $A^n$ to $A$ (namely, just $n$). The point is that a single term can have multiple different interpretations as functions, and these yield different arities. You point this out yourself.
Specifically, for any term $p$ and any set $V$ of variables such that every variable occurring in $p$ is in $V$, we can view $p$ as a map $p_V: A^V\rightarrow A$. Note that the translation $(p,V)\mapsto p_V$ is completely straightforward; this is why one will (sadly) often conflate $p$ and $p_V$ when $V$ is clear from context.
In light of this, it isn't too weird to allow a term to have multiple arities - the point being that in some sense a term on its own is incomplete (for spiritual similarity, one might argue that the graph of a function is incomplete since it doesn't tell you the codomain).