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.