How is the dominated convergence theorem applied here?
This result is only true for $p \in [1, \infty)$. Let me start by giving a counterexample for the case $p = \infty$. Let $E = [0,1]$ with its Borel $\sigma$-algebra and the Lebesgue measure. Let $A_n f := 1_{[0, 1-\frac1n]} f$ and $B = \operatorname{Id}$. It is easy to check that these are both contractions in $L^q$ for every $q \in [1,\infty]$ and to check that $$\|A_n f - Bf \|_{L^p} \to 0$$ for every $p \in [1, \infty)$, say by using the D.C.T. However if $f(x) = 1$ for all $x \in [0,1]$ then $\|A_n f - B f\|_\infty = 1$ for all $n$.
A proof for the case $p \in [1,\infty)$ was outlined in my comment, which I recreate here. First let $I_n = A_n f - B f$. By contractivity of $A_n,B$ in $L^\infty$, we can find an $L^\infty$ function $g$ such that $|I_n| \leq g$.
Now consider an arbitrary subsequence $I_{n_k}$. By the convergence in $L^2$, this subsequence has a further subsequence that converges a.e. Then, for $p \in [1,\infty)$, by the DCT with dominating function $|g|^p$, that further subsequence converges to $0$ in $L^p$.
The desired convergence then follows by a standard subsequences argument; a sequence $x_n$ in a topological space converges to $x$ if and only if every subsequence of $x_n$ has a further subsequence converging to $x$.
The answer given by Rhys Steele is of course perfectly fine. Here is an alternative argument: for $1\leqslant p\lt 2$, this follows from the fact that $\lVert g\rVert_p\leqslant\lVert g\rVert_2$ for all $g\in\mathbb L^2$. For $p>2$, write $$ \left\|(A_n-B)f\right\|_{L^p}^p=\mathbb E\left[\lvert A_nf-Bf\rvert^p\right] \leqslant\mathbb E\left[\lvert A_nf-Bf\rvert^2\right]\lVert A_nf-Bf\rVert_\infty^{p-2} $$ and $\lVert A_nf-Bf\rVert_\infty\leqslant 2\lVert f\rVert_\infty$ hence $$ \left\|(A_n-B)f\right\|_{L^p}^p\leqslant 2^{p-2}\lVert f\rVert_\infty^{p-2}\left\|(A_n-B)f\right\|_{L^2}^2. $$