As has been discussed in the comments, there are several approaches to this problem. Here is one of them in some detail.
Let $f : M \to \mathbb{R}^n$ be smooth, then $f = (f_1, \dots, f_n)$ where $f_i : M \to \mathbb{R}$ is the $i^{\text{th}}$ coordinate function. Let $p \in M$ and let $(U, (x^1, \dots, x^n))$ be a chart centred at $p$. Then in local coordinates, the derivative of $f$ at $p$ has standard matrix
$\left[\begin{array}{ccc} \frac{\partial f_1}{\partial x^1}(p) & \dots & \frac{\partial f_1}{\partial x^n}(p)\\ \vdots & & \vdots\\ \frac{\partial f_n}{\partial x^1}(p) & \dots & \frac{\partial f_n}{\partial x^n}(p)\end{array}\right].$
Note that $f_1 : M \to \mathbb{R}$ is smooth and $M$ is compact, so $f_1$ attains a maximum. If we denote by $p$ a point where $f_1$ attains its maximum, and use the coordinate system as above, we have
$\frac{\partial f_1}{\partial x^1}(p) = \dots = \frac{\partial f_1}{\partial x^n}(p) = 0.$
But then the standard matrix of the differential of $f$ at $p$ has a row of zeroes, and is therefore singular.
Note, we could have done this for any of the functions $f_i$. The approach would also work if $p$ were a point where one of the functions attained a minimum.