How does Tom Apostol deduce the inequality $\frac{k^3}{3} + k^2 \lt \frac{(k + 1)^3}{3}$ in section I 1.3 of his proof by induction example? In his book Calculus, Vol. 1, Tom Apostol writes the following proof for proving the following predicate by induction:
$$A(n): 1^2 + 2^2 + \cdots + (n - 1)^2 \lt \frac{n^3}{3}.$$
I have omitted the Base Case due to lack of specific relevance. An excerpt from the book's page:

Assume the assertion has been proved for a specific value of $n$, say $n = k$. That is, assume we have proved
$$A(k): 1^2 + 2^2 + \cdots + (k - 1)^2 \lt \frac{k^3}{3}$$
for a fixed $k \ge 1$. Now using this, we shall deduce the corresponding result for $k + 1:$
$$A(k + 1): 1^2 + 2^2 + \cdots + k^2 \lt \frac{(k + 1)^3}{3}.$$
Start with $A(k)$ and add $k^2$ to both sides. This gives the inequality
$$1^2 + 2^2 + \cdots + k^2 \lt \frac{k^3}{3} + k^2.$$
To obtain $A(k + 1)$ as a consequence of this, it suffices to show that
$$\frac{k^3}{3} + k^2 \lt \frac{(k + 1)^3}{3}.$$
But this follows at once from the equation
$$\frac{(k + 1)^3}{3} = \frac{k^2 + 3k^2 + 3k + 1}{3} = \frac{k^3}{3} + k^2 + k + \frac13.$$
Therefore, we have shown that $A(k + 1)$ directly follows from $A(k)$.

I can not understand the last two steps. Why do the expressions seem to flip on the inequality in step 4 such that $\frac{k^3}{3} + k^2$ is now on the other side of the less than symbol, and how does the final equation prove the assertion?
Thank you.

There's possibly a better way to see what's going on; instead of manipulating what you want to show, proceed from the left-hand side:
\begin{align}
1^2+2^2+\dots+(k-1)^2+k^2
&<\frac{k^3}{3}+k^2 && \text{(induction hypothesis)}\\[4px]
&=\frac{1}{3}(k^3+3k^2) && \text{(because we want $1/3$)}\\[4px]
&=\frac{1}{3}(k^3+3k^2+3k+1-3k-1) && \text{(complete the cube)}\\[4px]
&=\frac{1}{3}(k+1)^3-\frac{1}{3}(3k+1) && \text{(separate the cube)}\\[4px]
&<\frac{1}{3}(k+1)^3
\end{align}
