Why is $\sin : \mathbb{R} \to [-5,5] $ different from $\sin : \mathbb{R} \to \mathbb{R}$?
The difference that changing the codomains make is that you've changed the codomain; you no longer have what you started with.
There are actually two main conceptions of the notion of "function" floating around. For lack of a better name, I will call them the "typed" and the "untyped" version.
In the typed notion of function, the types of the input and output argument of a function are part of its identity. The fundamental concept here is "a function from A to B", so if you change B you're talking about something different. When one just says "function", that there is an A and a B associated to the function is still implicit; e.g. the specific choice of A and B can be deduced from context, or maybe we're saying something that will be true no matter what A and B are.
In the untyped notion of function, which I will just call a "graph", it's not bound to types; it's often conceived simply as a set containing possible input-output pairs. Given any pair of sets $A$ and $B$, we can ask if a graph can be construed as a function from $A$ to $B$. This is, I think, the notion you have in mind.
Your teacher is using "function" in the typed sense; you have in mind the notion of a graph instead.
As discussed in detail here, a function is a triple
a first set $A$ (domain)
a second set $B$ (codomain)
a law (i.e. a rule, a relationship, etc.) such that at each element of $A$ is associated one and only one element of $B$ that is
$$\forall x\in A \quad \exists ! y\in B:\,y=f(x)$$
Therefore in that case
- $\sin : \mathbb{R} \to [-5,5] $
- $ \sin : \mathbb{R} \to \mathbb{R} $
are different functions since they have different codomain.
To appreciate that definition consider the case
$f(x)=x^2 \quad \mathbb{R} \to \mathbb{R}$
$f(x)=x^2 \quad \mathbb{R^+} \to \mathbb{R}$
in that case the "law" is the same but only the second one is bijective and invertible.
Therefore when we define a function it is always necessary, in order to have a complete definition, to declare also its domain and codomain.