Consider a matrix $A= \begin{pmatrix} 1 & 2 & 1\\ 3 & 6 & 1\\ 0 & 4 & 1 \end{pmatrix}$
I am applying the transformations on matrix $A$ to convert it to $U$ using the following matrices:
(The i,j in $E_{ij}$ denotes the element in matrix A which is fixed in order to transform it into $U$)
$E_{21} = \begin{pmatrix} 1 & 0 & 0\\ -3 & 1 & 0\\ 0 & 0 & 1 \end{pmatrix}$
$E_{31} = I_{3\times3}$
$P = \begin{pmatrix} 1 & 0 & 0\\ 0 & 0 & 1\\ 0 & 1 & 0 \end{pmatrix}$
Now
$U = \begin{pmatrix} 1 & 2 & 1\\ 0 & 4 & 1\\ 0 & 0 & -2 \end{pmatrix}$
If i write everything in matrix notation: $PE_{31}E_{21}A = U$
How should i convert this into $PA = LU$?
Basically the idea behind writing a Gaussian elimination outcome in the form $PA=LU$ is that you could have done all the swaps at the beginning and then just done the row scaling/addition afterward.
So here suppose you had swapped 2 and 3 initially. The scale/add step that you would have done to zero out the first column wouldn't be the same, because now what used to be row 2 is in row 3, so where you had $\begin{pmatrix} 1 & 0 & 0\\ -3 & 1 & 0\\ 0 & 0 & 1 \end{pmatrix}$ you would now have $\begin{pmatrix} 1 & 0 & 0\\ 0 & 1 & 0\\ -3 & 0 & 1 \end{pmatrix}$. So you make these modifications to any $E$ matrices that were applied after the row swap (moving the off-diagonal entry to correspond to which rows were being combined in the matrix after all the row swaps).
So here specifically it will look like
$$\begin{pmatrix} 1 & 0 & 0\\ 0 & 0 & 1\\ 0 & 1 & 0 \end{pmatrix} A = \begin{pmatrix} 1 & 0 & 0\\ 0 & 1 & 0\\ 3 & 0 & 1 \end{pmatrix} U$$
where we flipped the sign of the $-3$ in the $L$ when we inverted the $E$ matrix (as usual).