We now subtract the appropriate multiples of the first row from the rows $i=2,\dots,n$ and the appropriate multiples of the first column from the columns $ji=2,\dots,n$.
Let us first find the multiple of the first row, to be subtracted from the second one, denoting it as ${\rm row}_2$. Since $p_{11}(\lambda) = \lambda$ and $p_{21}(\lambda) = \lambda^2$, we see that ${\rm row}_2$ equals the first row multiplied by $(p_{21}/p_{11})(\lambda) = \lambda$:
$${\rm row}_2 = (p_{21}/p_{11})(\lambda) \begin{bmatrix} \lambda & \lambda^2 \end{bmatrix} = \begin{bmatrix} \lambda^2 & \lambda^3 \end{bmatrix}.$$
We now subtract this from the current second row:
$$\begin{bmatrix} \lambda^2 & \lambda - 1 \end{bmatrix} - {\rm row}_2 = \begin{bmatrix} 0 & -\lambda^3 + \lambda - 1 \end{bmatrix}.$$
Our current $P(\lambda)$ is
$$P(\lambda) = \begin{bmatrix} \lambda & \lambda^2 \\ \color{red}{0} & \color{red}{-\lambda^3 + \lambda - 1} \end{bmatrix}.$$
As before, we subtracting the first column's multiple will now just remove the nonzeroes in the first row.
$$P(\lambda) = \begin{bmatrix} \lambda & \color{red}{0} \\ 0 & \color{red}{-\lambda^3 + \lambda - 1} \end{bmatrix}.$$
Now, this may seem great, but notice that $p_{11} \nmid p_{22}$, so we need further corrections. This is done by adding the second row to the first one, repeating the above procedure. So, we get
$$P(\lambda) = \begin{bmatrix} \color{red}{\lambda} & \color{red}{-\lambda^3 + \lambda - 1} \\ 0 & -\lambda^3 + \lambda - 1 \end{bmatrix} = \begin{bmatrix} \lambda & \color{red}{\lambda \cdot (-\lambda^2 + 1) + (-1)} \\ \color{red}{0} & -\lambda^3 + \lambda - 1 \end{bmatrix}.$$
We see that $q_{12}(\lambda) = -\lambda^2 + 1$ and $r_{12}(\lambda) = 1$. We need to subtract the first column times $q_{12}(\lambda)$ from the second colum:
$$P(\lambda) = \begin{bmatrix} \lambda & \color{red}{-1} \\ 0 & \color{red}{-\lambda^3 + \lambda - 1} \end{bmatrix}.$$
Exchanging these two, we get
$$P(\lambda) = \begin{bmatrix} -1 & \lambda \\ -\lambda^3 + \lambda - 1 & 0 \end{bmatrix}.$$
After eliminating $p_{12}$, we have
$$P(\lambda) = \begin{bmatrix} -1 & \color{red}{0} \\ -\lambda^3 + \lambda - 1 & \color{red}{-\lambda^4 + \lambda^2 - \lambda} \end{bmatrix}.$$
Then we eliminate $p_{21}$:
$$P(\lambda) = \begin{bmatrix} -1 & 0 \\ \color{red}{0} & \color{red}{-\lambda^4 + \lambda^2 - \lambda} \end{bmatrix}.$$
Repeat the process on the bottom right principal submatrix of order $n-1$. In our case, as above, $n = 2$, so the job is almost done, as we have
$$P(\lambda) = \begin{bmatrix} -1 & 0 \\ 0 & -\lambda^4 + \lambda^2 - \lambda \end{bmatrix}.$$
For this to be a Smith form, we need the nonzero diagonal polynomials to be monic (i.e., have a leading coefficient equal to $1$). In our case, we do this by multiplying $P(\lambda)$ by $-1$. In a more generale case, we'd need to multiply it from either left or right by some constant diagonal matrix.
Finally, we obtain
$$P(\lambda) = \begin{bmatrix} 1 & 0 \\ 0 & \lambda^4 - \lambda^2 + \lambda \end{bmatrix}.$$
Best Answer
Smith McMillan is a variation of the Smith Normal Form (SNF) for rational matrices. Basically all we have to do is factor out the least common multiple of the denominators to get a polynomial matrix and apply the SNF
$$ P = \begin{bmatrix} \frac{4}{(s+1)(s+2)} & \frac{-0.5}{s+1} \\ \frac{1}{s+2} & \frac{2}{(s+1)(s+2)}\\ \end{bmatrix} = \frac{1}{(s+1)(s+2)} \begin{bmatrix} 4 & -\frac{1}{2}(s+2) \\ s+1 & 2\\ \end{bmatrix} = \frac{1}{(s+1)(s+2)}L^{-1}(s) \begin{bmatrix} 1 & 0 \\ 0 & s^2 + 3s +18\\ \end{bmatrix} R^{-1}(s) $$
And to get the SNF of a matrix what you do is you multiply elementary matrices from the left and right. I.e. row/col swaps or adding a multiple of a row/col onto another. Obviously any constant entry will do.
You start by swapping an non-zero element to the 1-1 position that divides all other elements of the matrix.$^1$ $$\begin{bmatrix} 4 & -\frac{1}{2}(s+2) \\ s+1 & 2\\ \end{bmatrix}$$
So now you we can eliminate the other entries of the first row and column by multiplying the matrix $L_1$ that adds $ -\frac 14 (s+1)$ times the first row to the second and the matrix $R_1$ that adds $\frac 18(s+2) $ times the first column to the second from the left/right:
$$ \underbrace{\begin{bmatrix} 1 & 0 \\-\frac 14 (s+1) & 1 \end{bmatrix}}_{L_1} \cdot \begin{bmatrix} 4 & -\frac{1}{2}(s+2) \\ s+1 & 2\\ \end{bmatrix} \cdot \underbrace{\begin{bmatrix} 1 & \frac 18(s+2) \\0 & 1 \end{bmatrix}}_{R_1} = \begin{bmatrix} 4 & 0 \\ 0 & \frac 18 (s+1)(s+2) + 2 \end{bmatrix} $$
And now we only need to normalize by multplying the first row/col by $\frac 14$ and $8$ respectively, which we do by setting
$$ L = \begin{bmatrix} \frac{1}{4} & 0 \\ 0 & 8 \end{bmatrix} \cdot L_1 = \begin{bmatrix} \frac{1}{4} & 0\\ -2(s+1) & 8 \end{bmatrix} $$
$^1$If such an element does not exist, we take a non-zero element of minimal degree and perform Euclids algorithm and use it to reduce all other elements, then try again.