Say I have a function $f(x) = x^2$. Can this be a surjective function? If I'm getting the unto and 1-1 concepts right, $f(x) = x^2$ is always 1-1 as $x$ always maps distinct objects in codomain ($x^2$).
But it's not a surjective function since you can't get all $x$ in codomain. But if I restrict my domain $x$ to be in set of values in codomain, then this function $f(x) = x^2$ can be surjective, depending on the context.. is that right?
 A: It depends on what the domain and codomain are specified to be, so yes, the status of a function being one-to-one and/or onto depends on "context"; in particular, it depends on the function's definition, and part of that definition includes a specification of the domain and codomain.
For example, suppose we define $f$ as follows: $$f:\mathbb R \to \mathbb R,\quad f(x) = x^2$$
Then $f$ is not one-to-one, nor onto. Why not? 
Not One-to-one: 
What is $f(-3)$? What is $f(3)$? Note that $f(-3) = f(3),$ but $\;-3\neq 3.\;$ So the function is not one-to-one. 
Recall: A function is one-to-one if and only if for each $a, b$ in the domain, $$f(a) = f(b) \implies a = b$$ or equivalently, if $$a \neq b \implies f(a)\neq f(b)$$
Nor is it surjective: Recall that a function $f$ is surjective if and only if for every element $y$ in the codomain, there exists an $x$ in the domain such that $f(x) = y$. In the case at hand, for example, there is no $x$ such that $y = f(x) = x^2 = -4$. 

However, if you restrict the domain and codomain to non-negative reals in this case, which we can denote $\mathbb R_{\geq 0},$ then the function $f$ defined by: $$f: \mathbb R_{\geq 0} \to \mathbb R_{\geq 0}, \quad f(x) = x^2$$  is both one-to-one and onto.
A: In the finite fields with number of elements given by a power of $2$, $\mathbb F_{2^k}$ the squaring map is an automorphism!
More generally in a finite field with $q$ elements where $q=p^k$ and $p$ is prime, then the $p^{th}$ power map is an automorphism called the Frobenius automorphism. We actually could get away with $p$ itself being a prime power, and the same result is true. 
