Since $f$ has a finite limit at each point of $K$, for each point $x_0\in K$, there is a $\delta>0$ such that $|f(x)-L|<1$, i.e. $f$ is bounded in $(x_0-\delta, x_0+\delta)$. Since it holds for any point $x_0\in K$, $K\subset\bigcup_{x_0\in K}(x_0-\delta, x_0+\delta)$, i.e. an open cover of $K$. Since $K$ is compact, there is a finite subcover that $K\subset\bigcup_{1\leqslant i\leqslant N}(x_i-\delta, x_i+\delta)$. Then $|f|<M$ on $K$ if we set $M=\max{(M_1,\cdots, M_N)}$, where $|f|<M_i$ on $(x_i-\delta, x_i+\delta)$. So $f$ is bounded on $K$.
If $f$ doesn't have finite limit at each point of $K$, $f$ may not be bounded on $K$ for it may not be bounded on $(x_0-\delta, x_0+\delta)$.