If you have $n$ characters $1,2,3,...,n$ count the number of three-letter words that can be formed.
Using the multiplication principle, the first letter can have $n$ choices, and so do the second and last. That gives $n\cdot n\cdot n=n^3$.
Let's do the counting in a second way.
Put one letter aside $1$. How many words use the other $n-1$ letters? $(n-1)^3$.
How many words use the $1$ in one of the letters and the other $n-1$ in the other two? $3$ choices for which letter is the one that is $1$, and $(n-1)^2$ for the other two letters. That is $3(n-1)^2$. Finally, the number of words that use $1$ twice. That is $3(n-1)$. Finally, there is one words $111$ using only the $1$.
Together the count is $(n-1)^3+3(n-1)^2+3(n-1)+1$.
If you have $n$ characters $1,2,3,...,n$ count the number of three-letter words that can be formed.
Using the multiplication principle, the first letter can have $n$ choices, and so do the second and last. That gives $n\cdot n\cdot n=n^3$.
Let's do the counting in a second way.
Put one letter aside $1$. How many words use the other $n-1$ letters? $(n-1)^3$. How many words use the $1$ in one of the letters and the other $n-1$ in the other two? $3$ choices for which letter is the one that is $1$, and $(n-1)^2$ for the other two letters. That is $3(n-1)^2$. Finally, the number of words that use $1$ twice. That is $3(n-1)$. Finally, there is one words $111$ using only the $1$.
Together the count is $(n-1)^3+3(n-1)^2+3(n-1)+1$.