Step 1: Express matrix \(A\) in terms of identity matrix.
Given,
\[
A=\begin{bmatrix}
n & 0 & 0\\
0 & n & 0\\
0 & 0 & n
\end{bmatrix}
\]
So,
\[
A=nI
\]
Step 2: Find \(A^2\).
\[
A^2=(nI)^2
\]
\[
A^2=n^2I
\]
Step 3: Find \(B^2\).
Given,
\[
B=\begin{bmatrix}
0 & 0 & n\\
0 & n & 0\\
n & 0 & 0
\end{bmatrix}
\]
Multiplying \(B\) by itself,
\[
B^2=
\begin{bmatrix}
0 & 0 & n\\
0 & n & 0\\
n & 0 & 0
\end{bmatrix}
\begin{bmatrix}
0 & 0 & n\\
0 & n & 0\\
n & 0 & 0
\end{bmatrix}
\]
\[
=
\begin{bmatrix}
n^2 & 0 & 0\\
0 & n^2 & 0\\
0 & 0 & n^2
\end{bmatrix}
\]
Therefore,
\[
B^2=n^2I
\]
Step 4: Find \(AB\).
Since
\[
A=nI
\]
we get
\[
AB=(nI)B
\]
\[
AB=nB
\]
Step 5: Add \(A^2+B^2+AB\).
\[
A^2+B^2+AB=n^2I+n^2I+nB
\]
\[
=2n^2I+nB
\]
Taking \(n\) common,
\[
= n(2nI+B)
\]
Step 6: Final conclusion.
Therefore,
\[
\boxed{n(2nI+B)}
\]