We have the following definition:
Definition: let $*_A:A^2 \rightarrow A$ and $B \subseteq A $, with $B \neq \emptyset$, $B$ is closed under $*_A$ if $a *_A|_Bb \in B$ $\forall a,b \in B$.
Property: let $*_A:A^2 \rightarrow A$ and $A$ is closed under $*_A$, then $a *_A b \in A$ $\forall a,b \in A$
Proof: by hypothesis $A$ is closed under $*_A$ then for all $a,b \in A$ we have $a *_A|_Ab \in B$, but $*_A|_A:A^2 \rightarrow A$ is restriction function of $*_A$ on $A$ and for all $a,b \in A$ we have $a*_A|_Ab=a *_A b$, therefore $a *_A b \in A$ by Leibniz's Law.
It is correct?
By definition, if you're given a function $*:A\times A\to A$, $*(a,b)=a*b\in A$ for any $a,b\in A$. This is simply because the function is defined to have codomain $A$, that is, any pair of elements $a,b\in A$ are by definition sent to an element $*(a,b)=a*b$ which is in $A$. This is in general written as
It makes sense to consider subsets of $A$, and ask whether the image of $B\times B$ under $*$ is contained in $B$, that is, if $$*\mid_{B\times B}:A\times A\to A$$ is such that $$\operatorname{Im}(*\mid_{B\times B})\subseteq B$$
And example would be the mapping $$*:\Bbb Z\times \Bbb Z\to \Bbb Z$$ that maps $$n*m\to nm+n+m$$
In this case, $*\mid_{\Bbb N}$ is an operation on $\Bbb N$ because $mn+m+n$ will be a natural for any pair of natural numbers $m,n$.
ADD Consider an example that fails, $$*:\Bbb Z\times \Bbb Z\to\Bbb Z$$ defined via $$*(a,b)=a+(-b)$$
This is not an operation in $\Bbb Z_{>0}$, for example.