Strictly speaking, $f(x,y)=\sqrt{xy}$ is not a function at all. It becomes a function when you specify a domain and a codomain. Depending on your domain, you may have alternative ways to write the function; for example, if you choose the domain $\{(x,y)\in\mathbb R^2: xy=1\}$ you can equivalently write the function as $f(x,y)=1$; this form clearly is not equivalent to your expression if you chose as domain e.g $\{(x,y)\in\mathbb R^2: x>0\land y>0\}$. And of course you have to make sure that your expression is defined on the complete domain, or alternatively, use it only for the corresponding part of the domain and give another expression for other parts of the domain. For example, on the domain $(x,y)\in\mathbb R^2: xy\ge 0$, you could write your function equivalently as
$$f(x,y) = \begin{cases} x^{1/2}y^{1/2} & x\ge 0 \\ (-x)^{1/2}(-y)^{1/2} & \text{otherwise}\end{cases}$$
Usually when not specifying a domain, the domain is implicitly given as “whereever that expression is defined”. In that sense, the two functions you give are then not the same, as they have different domains, although they agree in the intersection of their domains.
Note also that without codomain, your function is not completely defined. For example, if you chose $\mathbb R_{\ge 0}$ as your codomain, your function (with implicitly given domain) is surjective (it reaches every point of the codomain), while with the codomain $\mathbb R$ it isn't.
If not explicitly specified, usually the codomain of a function is assumed either to be its image (the minimal possible codomain, which makes the function surjective), or the largest “reasonable” set containing the image (like $\mathbb R$ for real-valued functions).
Since the exact codomain is less often relevant than the domain, it is more often left unspecified.