Value of constants when a limit is finite? 
If  $\displaystyle \lim_{x\to0}\frac{a\cos x+bx\sin x-5}{x^4}$ is finite. Find the value of 'a' and 'b'.

$$\lim_{x\to0}\frac{a\left[1-\frac{x^2}{2!}+\frac{x^4}{4!}....\right]+bx\left[x-\frac{x^3}{3!}+\frac{x^5}{5!}....\right]-5}{x^4}$$
$$\implies\lim_{x\to0}\frac{a-5+a\left[-\frac{x^2}{2!}+\frac{x^4}{4!}....\right]+bx\left[x-\frac{x^3}{3!}+\frac{x^5}{5!}....\right]}{x^4}$$
Here we take $a-5=0$ or  $a=5$
And then we proceed further, equating constant terms (terms which do not hold 'x' of any degree) to zero and finding the values.

But if we take the case of:
$$\lim_{x\to0}\frac{6+x^2-6e^x}{x}=\lim_{x\to0}2x-6e^x=-6$$
(using L'Hopital Rule) is a finite limit, but in this case the independent value '6' is not equal to zero. So why do we assume in the above case that the independent values 'a','b' etc. when summed up gives zero?
Hope the question is clear.

The main problem with your thinking is that the coefficient of limit must not always be zero. Only the coefficient of terms that give undefined limit such as $x^{-k},k>0,k\in\mathbb Z$ must be zero, rest all can be anything.
"equating constant terms (terms which do not hold 'x' of any degree) to zero"
is wrong, actually 
"equating constant terms (terms which hold 'x' of degree less than denominator) to zero"

$$\lim_{x\to0}\frac{a\cos x+bx\sin x-5}{x^4}=\lim_{x\to0}\frac{a\color{fuchsia}{(1-x^2/2+x^4/24+O(x^6))}+bx\color{blue}{(x-x^3/6+O(x^5))}-5}{x^4}\\=\lim_{x\to0}\frac{\color{red}{x^0}(a-5)+\color{red}{x^2}(-a/2+b)+\color{green}{x^4}(a/24-b/6)+\color{green}{O(x^6)}}{x^4}$$
So $a=5$ and $b=a/2=5/2$ since $\displaystyle \lim_{x\to0}\frac{\color{red}{x^0}}{x^4},\frac{\color{red}{x^2}}{x^4}$ are undefined, so we rid of these terms by making their coefficient zero.

$$\lim_{x\to0}\frac{6+x^2-6e^x}{x}=\lim_{x\to0}\frac{6+x^2-6\color{red}{(1+x+x^2/2+O(x^3))}}{x}=\lim_{x\to0}\frac{-6x+O(x^2)}{x}=-6$$

$$\lim_{x\to0}\frac{a+x^2-ae^{x}}{x}=\lim_{x\to0}\frac{a+x^2-a\color{red}{(1+x+x^2/2+O(x^3))}}{x}=\lim_{x\to0}\frac{-ax+3x^2/2+O(x^3)}{x}=-a$$
