$2\mid n \,\Rightarrow\, 8\mid \color{#0a0}{n^3},\,$ else $\,(n,2)\!=\!1 \,\Rightarrow\, 8\mid \color{#c00}n^{\color{#c00}2k}-1\ $ by $\,\color{#c00}{{\rm odd}^2}\equiv \{\pm1,\pm3\}^2\equiv 1 \pmod{\!8}$
$3\mid n \,\Rightarrow\, 3\mid\color{#0a0}{n^3},\,$ else $\,(n,3)\!=\!1 \,\Rightarrow\, 3\mid \color{#c00}n^{\color{#c00}2k}-1\ $ by $\,n\not\equiv0\,\Rightarrow\, n\equiv\pm1\,\Rightarrow\,\color{#c00}{n^2}\equiv 1\pmod{\!3}$
In all cases $\,\color{#0a0}{n^3}(\color{#c00}n^{\color{#c00}2k}-1)\,$ is divisible by $8$ and $3$ so it is divisible by their lcm = product $= 24$.
Remark $ $ The same idea works for any primes if we use Euler vs. brute-force case analysis.
Theorem $\ $ For primes $\rm\:p \ne q\:,\:$ naturals $\rm\:e,\:$ and $\rm\ j,\ k \:\le\: d\ $
$$\rm\quad\quad\ \phi(p^j),\ \phi(q^k)\ |\ e\ \ \Rightarrow\ \ p^j\ q^k\ |\ n^d(n^e - 1)\ \ \ \forall\ n\in \mathbb N $$
Proof $\ $ If $\rm\ p\ |\ n\ $ then $\rm\ p^j\ |\ n^d\ $ by $\rm\ j\le d\:.\:$ Else $\rm\:n\:$ is coprime to $\rm\: p\:,\:$ so by Euler's little theorem we have $\rm\bmod p^j\!:\ n^{\phi(p^j)}\equiv 1\ \Rightarrow\ n^e\equiv 1\ $ by $\rm\ \phi(p^j)\ |\ e\:.\ $ Thus $\rm\ n^d\ (n^e - 1)\ $ is divisible by $\rm\ p^j\ $ and, similarly it is divisible by $\rm\ q^k\:,\ $ hence it is also divisible by their lcm = product. $\quad$ QED
In fact for $\rm\ p = 2,\ j > 2\ $ we can use $\rm\ \phi(2^j)/2\ $ vs. $\rm\ \phi(2^j)\ $ because $\rm\ \mathbb Z/2^j\ $ has multiplicative group $\rm\ C(2)\times C(2^{j-2})\ $ for $\rm\ j> 2\:$. For more see a post on the Fermat-Euler-Carmichael theorem.
Generalization: $\ 24\,$ is the largest $m$ such that $\,m\mid n^2-1\,$ for all $\,n\,$ coprime to $\,m.\,$ This theorem is at the heart of many deductions in (elementary) number theory (and also in some more advanced exotic contexts, e.g. see Moonshine beyond the Monstor).