To illustrate what I'm trying to say in the title, consider the following limit. $$\lim_{x\to 0} \frac{\frac{\sin x}{x}-1}{x}$$ This, you might notice, is a derivative, but that is not relevant, it's simply an example I have at hand right now. My initial thought to solve such a limit, as $\lim_{x\to 0}\frac{\sin x}{x}= 1$, is to write $\lim_{x\to 0}\frac{1-1}{x}=\lim_{x\to 0}\frac{0}{x} = 0$, which IS correct, that is the value of the limit but I'm 90% sure it is only an accident this approach works. Instead, what I'm sure is correct is $$\lim_{x\to 0}\frac{\frac{\sin x}{x}-1}{x} = \lim_{x\to 0} \frac{\sin x - x}{x^2}=\left(\frac00\right)\underset{\overbrace{\text{ so I can apply L'Hopital}}}{=}\\=\lim_{x\to 0} \frac{\cos x - 1}{2x} =\lim_{x\to 0} \frac{-\sin x}{2} = 0$$
My question is quite basic: when am I allowed to substitute terms with well-known limits, like I tried to in the first "solution"? Was that first attempt correct or is it a coincidence the result is also $0$, like I suspect? My teacher tried to explain this, but he was rather vague. I think he mentioned that finite factors that are not equal to $0$ can be given the value of their limit and even brought in front of the limit as a normal number. What about when there is a fraction and the denominator's limit is $0$? What are some other cases I need to be aware of?
I'm trying to fundamentally understand what I'm allowed to do and what is illegal, so to speak, so any help is much appreciated!