If $\det(A)=0$, then you have $\det(A)\det(B) = 0 = \det(AB)$, so there is nothing to do. So all you need to do is consider the case where $A$ is invertible, i.e., where $\det(A)\neq 0$.
To show the result holds if $B$ is not invertible (not necessary, but you ask about it) notice that if $B$ is not invertible then neither is $AB$ (since there exists a nontrivial solution to $B\mathbf{x}=\mathbf{0}$, and this nontrivial solution is also a nontrivial solution to $AB\mathbf{x}=\mathbf{0}$, so $AB$ is not invertible either). So $\det(AB)=0$, and equality holds.
The key to the argument the book uses is that if $A$ is invertible, then it can be written as a product of elementary matrices: $A = E_1\cdots E_t$. These elementary matrices correspond to the elementary row operations performed to get rrefA (in the order of the indices). But when you left-multiply any matrix by an elementary matrix, then you perform the corresponding elementary row operation on the matrix.
Now, what happens if $A$ is just an elementary matrix, and you look at $\det(AB)$? If $A$ is an elementary matrix corresponding to a swap of rows, then $AB$ is the result of swapping rows of $B$, so $\det(AB) = -\det(B)$. But if $A$ is an elementary matrix corresponding to a swap of rows, then $\det(A) = -1$. So in this case, $\det(AB) = -\det(B) = \det(A)\det(B)$.
If $A$ corresponds to adding a multiple of one row to another row, then $\det(A)=1$ and $\det(AB) = \det(B) = \det(A)\det(B)$.
Finally, if $A$ corresponds to multiplying a row by $k$, then $AB$ is the result of multiplying a row of $B$ by $k$, so by the properties of the determinant you have that $\det(AB) = k\det(B)$; but again, $\det(A) = k$, so $\det(AB)=k\det(B)$ = \det(A)\det(B).
So the result works if A is an elementary matrix.
Now, how do the E_i$ correspond to the operations you do when you compute the rref of $A$? They are the opposite of what you do to $A$ to get the rref: because if $F_1,\ldots,F_t$ are what you do to $A$ to get the rref of $A$, then $F_t\cdots F_1 A = I$, so $A = (F_t\cdots F_1)^{-1} = F_1^{-1}\cdots F_t^{-1}.
The inverse of an elementary matrix corresponding to a swap of rows is an elementary matrix corresponding to a swap of rows; the inverse of an elementary matrix corresponding to adding a multiple of one row to another is an elementary matrix corresponding to adding a multiple of one row to another; and the inverse of an elementary matrix that corresponds to dividing a row by k$ is the elementary matrix that corresponds to multiplying a row by $k.
So, to see how E_1$, $E_2,\ldots,E_t$ affect $\det(B)$ when you compute $\det(E_1\cdots E_tB)$, you only need to keep track of (i) the number of times you swapped rows; and (ii) the constants you divided the rows of $A$ by to get the rref of $A$. Each row swap multiplies the determinant by $-1$, and dividing a row of $A$ by $k$ multiplies the determinant by $k$. So, if $s$ is the number of times you swapped rows, and $k_1,\ldots,k_r$ are the constants by which you divided rows of $A$, then $\det(AB) = \det(E_1\cdots E_t B) = (-1)^sk_1\cdots k_r\det(B),$ which is the step you were having trouble with.
I hope that helps.