According to this link, in order to introduce a new function symbol one needs to prove the formula $\forall x_1,...,x_n\exists!y:P(y,x_1,...,x_n)$. This allows for the introduction of a new $n$-ary function symbol $f$ accompanied by the axiom $\forall x_1,...,x_n:P(f(x_1,...,x_n),x_1,...,x_n)$.
The most common example I have seen is the one of introducing the notation $f(x)=y$ for a function $f:X \to Y$ of some sets $X$ and $Y$. However, in order to even talk about functions, one needs to assume that $X$ and $Y$ are sets and that $f$ is a function between these two sets. Thus one is in the situation that $\forall X,Y,f,x \exists!y :P(y,X,Y,f,x)$ for the appropriate $P$. Thus one would only be allowed to introduce a $4$-ary function symbol that is distinct from $f$ to denote that $y$, so something like $A(X,Y,f,x)$.
$(1)$ This leads to the question, why it is allowed to introduce $f(x)$? Wouldn't it have to be something like the $A$ I introduced above, meaning a $4$-ary symbol and not a $1$-ary symbol?
My guess is that the technically the function symbols are always introduced in context where $X$ and $Y$ are already assumed to be sets, so for example when one wants to prove a statement of the form $\forall X,Y :P(X,Y),$ where $X$ and $Y$ are sets. In the proof of such a statement one would assume that $X$ and $Y$ are sets (thus fixed). If one can then prove that there is a function $f:X \to Y$ then one knows that $\forall x \in X \exists !y \in Y: (x,y) \in f$. In this context one would be allowed to introduce a new $1$-ary function symbol $B$ alongside the axiom $\forall x \in X:(x,B(x)) \in f$.
$(2)$ So technically we cant use the symbol $f$ for $B$ here, right? In particular the symbol $f$ already is in use, so one can't use it for a new function symbol I suppose. I guess one is just being informal here?
$(3)$ The predicate $P$ includes the unbound variables $X,Y$ and $f$ here. Is this allowed for predicates in FOL? Or must every predicate only include bound variables?
$(4)$ If my guess is the answer to the question $(1)$, this would mean that the notation $f(x)=y$ for a function $f$ would not be introduced globally right? So whenever one deals with a function, one would have to introduce the function symbol again and again, right?