A function is both a rule and a domain on which that rule takes place. If, for two functions, the rule and the domain are the same, then the two functions are the same. Just to be clear, you gave several different rules, but they are all equivalent, i.e., they all agree for any $x$ you insert. And all of them have the same domain. So, they are all the same function. Which definition is best only depends on what you are working on.
For example, when you want to find the $\lim\limits_{x \to 0^-} \frac{|x|}{x}$, then any of your definitions will do just fine, and all work better than say $|x| = \max\{x, -x\}$ or $\sqrt{x^2}$.
$\lim_{x \to 0^-} \frac{|x|}{x} = \lim_{x \to 0^-} \frac{-x}{x} = \lim_{x \to 0^-} -1 = -1$
But, in other situations, maybe you'd prefer $\sqrt{x^2}$ for some reason.