Let us start with proving the existence of smallest period.
Lemma : Let $f:\mathbb{R}\to\mathbb{R}$ be a non-constant, continuous, and periodic function. Then, there exists a positive $p^*\in\mathbb{R}$ such that for every $x\in\mathbb{R}$, $f(x+p^*) = f(x)$, and for every other period $p$, $p\geq p^*$.
Proof : Construct the set of all periods of $f$:
$$
T \triangleq \{p>0 : f(x+p)=f(x),\forall x \in\mathbb{R}\}.
$$
Clearly by assumption, $T$ is non-empty, and bounded below by $0$. Hence, $p^* \triangleq \inf T$ exists.
Case 1 $p^*>0$. In this case, take a sequence of periods $p_n \to p^*$ (by definition of $p^*$, such a sequence always exists). Fix any $x\in\mathbb{R}$, and note that
$$
x+p_n\to\ x+p^* \implies \underbrace{\lim_{n\to\infty}f(x+p_n)}_{=f(x)} = f(x+p^*)
$$
where, we have made use of the fact that $f$ is continuous. Hence, $f(x) = f(x+p^*)$, for every $x \in \mathbb{R}$, therefore, $p^* \in T$.
Case 2 We need to rule out the case $p^* = 0$. In this case, there exists a sequence of periods $p_n \to 0$. Now, fix an $x$, and $\epsilon>0$. Due to continuity at $x$, there exists a $\delta>0$ such that
$$
|x-y|<\delta \implies |f(x)-f(y)|<\epsilon.
$$
Now, take a period $p<\delta$. We argue that for every $y$, there exists an $n \in \mathbb{Z}$ such that $|x+np - y|<\delta$. A simple, a bit incomplete reasoning is as follows. Suppose $y>x$. The sequence $x+np \to \infty$, as $n\to\infty$. Hence, at some point, it should cross $y$.
With this, we can conclude that for any other $y$,
$$
|f(x+np)-f(y)|<\epsilon \implies |f(x)-f(y)|<\epsilon.
$$
Since $\epsilon>0$ is arbitrary, we conclude that $f(\cdot)$ must be a constant function.
With the lemma above, we conclude that $f$ has a smallest period $p^*>0$. Now, we are almost done. Suppose $p$ is some period of $f(\cdot)$ that cannot be expressed as $kp^*$ for some $k\in\mathbb{N}$. Then, there exists a $k \in\mathbb{N}$ such that
$$
kp^* < p < (k+1)p^* \implies p = kp^* + \bar{p}, 0<\bar{p}<p^*.
$$
But in this case, we have $f(x) = f(x+p) = f(x+kp^* +\bar{p}) = f(x+\bar{p})$, for every $x$, hence $\bar{p}$ is also a period of $f$, contradicting with the fact that $p^*$ is the smallest period. We are done.