I'm a bit confused here. When we take the derivative of $$f(x)=\begin{cases} x^2\sin{\biggl(\dfrac{1}{x}\biggr)}&x\neq0\\ 0 &x=0\\ \end{cases} $$ It's derivative is not defined at $x=0$ as $f(x)=2x\sin{\biggl(\dfrac{1}{x}\biggr)}-\cos{\biggl(\dfrac{1}{x}\biggr)}$.
However, approaching this problem through the limit form of the derivative gives the value of the derivative at $x=0$: $$f'(x)=\lim_{h\to 0}\dfrac{f(x+h)-f(x)}{h}$$ $$\implies f'(0)=\lim_{h\to0}\dfrac{h^2\sin{\biggl(\dfrac{1}{x}\biggr)}-0}{h}=0$$
What I'm curious about here is why differentiating $f(x)$ first and then entering $x=0$ is failing in contrast to finding the derivative through limits?