For each $n\in \mathbb N$, let $f_n(x)=\begin{array}{cc} \Bigg\{ & \begin{array}{cc} nx^2 & 0\leq x\leq \frac{1}{n} \\ x & \frac{1}{n}<x \leq 1 \end{array} \end{array}.$
(a) Show that the function $f_n$ converges to a function in $f$ on $[0.1].$
(b) Find $M_n,$ $$M_n=\sup_{x\in [0,1]}|f_n(x)-f(x)|.$$ Show that the sequence of functions $f_n$ converges to $f$ uniformly.
My attempt
I am not able to prove this using definition.

You were correct about finding the limit function of your sequence. Now we will find $M_n$ and with that show the uniform convergence of $(f_n)$ to $f$.
For an arbitrary $n \in \mathbb{N}$ we see that $f_n$ differs from $f$ only on the interval $[0,\frac1n$], thus it suffices to look for the supremum only on that interval:
$$M_n = \sup_{x \in [0,1]}|f_n(x) - f(x)| = \sup_{x \in [0, \frac1n]}|f_n(x) - f(x)| = \sup_{x \in [0, \frac1n]}|nx^2 - x| = \frac{1}{4n} $$
Now that we found $M_n$ let's show the uniform convergence by definition.
Let $\epsilon > 0$. Since $\big(\frac{1}{4n}\big)_{n \in \mathbb{N}}$ converges to $0$, we know there exists an $N \in \mathbb{N}$, such that for all $n \geq N$ the following inequality holds:
$$\frac{1}{4n} < \epsilon.$$
Thus for an arbitrary $x \in [0,1]$ we have:
$$|f_n(x)-f(x)| \leq \sup_{x \in [0,1]}|f_n(x) - f(x)| = M_n = \frac{1}{4n} < \epsilon,$$
for all $n \geq N$, which by definition shows uniform convergence of $(f_n)$ on $[0,1]$.