What does a set of functions from $A$ to $B$ belong to? To understand the set-theoretic definition of functions, I tried to find a set that contains a set of all functions from $A$ to $B$ for (possibly empty) sets $A$ and $B$.
$
\newcommand{\eqv}{\Leftrightarrow}
\newcommand{\imply}{\Rightarrow}
\newcommand{\powset}{\mathcal{P}}
$
My approach (possibly informal):
Because a function is a subset of binary relation,
$$
f \in A \to B
\imply
f \subseteq A \times B
\imply
f \in \powset(A \times B)
$$
where $A \to B$ denotes the set of all functions from $A$ to $B$.
Therefore,
$$
\forall f: f \in A \to B \imply f \in \powset(A \times B)
$$
i.e., $A \to B \subseteq \powset(A\times B)$.
Finally, we have
$$
A \to B \in \powset(\powset(A\times B))
$$
Is this correct? What is the domain of discourse of $f$ here? (concerning $\forall f$)

Yes, the set of maps from $A$ to $B$ is a subset of $\mathcal{P}(\mathcal{P}(A \times B))$.  It is more often written $B^A$ than $A \to B$.  In the statement
$(\forall f) (f \in B^A \Rightarrow f \in \mathcal{P}(A \times B))$, the domain of discourse is the not-a-set of all sets, assuming that you're working in ZFC.
