In general, the answer is that you can't expect this kind of substitution to work; for instance, if you tried it on something like
and replaced $\sin(x)$ by $0$ since $\sin(0)=0$, you would get the wrong answer. Basically, you're not allowed to take apart a limit like that without further justification. At some level, your observation is coincidental - sometimes the answer changes when you substitute for a trigonometric function and sometimes the answer is right even after you substitute for an exponential.
This said, there is a deeper reason here: $1$ is a better approximation to $\cos(x)$ than it is to $e^x$ near $0$. In particular, $e^x=1+x+x^2/2+x^3/6+\ldots$ and $\cos(x)=1-x^2/2+\ldots$. You can see that replacing $\cos(x)$ by $1$ preserves the value of the function at $x=0$ and the derivative there. This cannot be said of replacing $e^x$ by $1$. As it happens, $1$ is close enough to $\cos(x)$ to not matter here - but that's pretty much just chance.
More formally stated, one often talks about "error" in terms of big $O$ notation, where you can write $\cos(x)=1+O(x^2)$, meaning that $\cos(x)-1$ vanishes at least as fast as $x^2$ as $x$ goes to $0$. Then $e^x=1+O(x)$, meaning $e^x-1$ vanishes only as fast as $x$ as $x$ goes to $0$. You can see that $x^2$ shrinks faster than $x$ near $0$, so the former is a better approximation. You would see a similar result if you tried taking a Taylor expansion of the numerator and denominator to solve the limit.