[proofplan]
We prove both implications. If $\mathrm{P}=\mathrm{NP}$, then the membership part of NP-completeness gives $B \in \mathrm{NP}$, hence $B \in \mathrm{P}$. Conversely, if $B \in \mathrm{P}$, then every language $A \in \mathrm{NP}$ reduces to $B$ by NP-hardness, and composing the reduction with a polynomial-time decider for $B$ gives a polynomial-time decider for $A$. Finally, $\mathrm{P} \subseteq \mathrm{NP}$ follows directly from the verifier definition by ignoring the certificate.
[/proofplan]
[step:Use membership in $\mathrm{NP}$ to prove the forward implication]
Assume $\mathrm{P}=\mathrm{NP}$. Since $B$ is NP-complete, by definition $B \in \mathrm{NP}$. Therefore $B \in \mathrm{P}$, because the two classes are equal under the present assumption.
[/step]
[step:Compose an NP-hardness reduction with a polynomial-time decider for $B$]
Assume $B \in \mathrm{P}$. Let $A \subseteq \Sigma^*$ be an arbitrary language with $A \in \mathrm{NP}$. Since $B$ is NP-complete, it is NP-hard with respect to polynomial-time many-one reductions. Hence there exists a polynomial-time computable map
\begin{align*}
f:\Sigma^* \to \Sigma^*
\end{align*}
such that, for every word $x \in \Sigma^*$,
\begin{align*}
x \in A \iff f(x) \in B.
\end{align*}
Since $B \in \mathrm{P}$, there exists a deterministic Turing machine $M_B$ deciding $B$ in time bounded by a polynomial $q:\mathbb{N} \to \mathbb{N}$. Since $f$ is polynomial-time computable, there exists a deterministic Turing machine $M_f$ computing $f$ in time bounded by a polynomial $p:\mathbb{N} \to \mathbb{N}$.
Define a deterministic Turing machine $M_A$ as follows: on input $x \in \Sigma^*$, first run $M_f$ on $x$ to compute $f(x)$, and then run $M_B$ on $f(x)$. The machine $M_A$ accepts exactly when $M_B$ accepts $f(x)$. By the equivalence defining the reduction, $M_A$ decides $A$.
The running time of $M_A$ is polynomial in $|x|$: the first stage takes at most $p(|x|)$ steps, and the output length $|f(x)|$ is bounded by a polynomial in $|x|$ because a polynomial-time machine can write only polynomially many symbols. Thus the second stage takes at most $q(|f(x)|)$ steps, which is also bounded by a polynomial in $|x|$. Therefore $A \in \mathrm{P}$.
[guided]
The goal is to show that the assumption $B \in \mathrm{P}$ forces every language in $\mathrm{NP}$ to be in $\mathrm{P}$. So fix an arbitrary language $A \subseteq \Sigma^*$ with $A \in \mathrm{NP}$. Because $B$ is NP-complete, it is not merely in $\mathrm{NP}$; it is also NP-hard. The NP-hardness condition gives a polynomial-time many-one reduction from $A$ to $B$. Concretely, this means there is a polynomial-time computable map
\begin{align*}
f:\Sigma^* \to \Sigma^*
\end{align*}
such that, for every input word $x \in \Sigma^*$,
\begin{align*}
x \in A \iff f(x) \in B.
\end{align*}
This equivalence is the whole reason reductions are useful: deciding whether $x$ belongs to $A$ can be converted into deciding whether the transformed input $f(x)$ belongs to $B$.
Now use the hypothesis $B \in \mathrm{P}$. This gives a deterministic Turing machine $M_B$ deciding $B$ in polynomial time. Let $q:\mathbb{N} \to \mathbb{N}$ be a polynomial bounding the running time of $M_B$. Since $f$ is polynomial-time computable, there is also a deterministic Turing machine $M_f$ computing $f$, with running time bounded by a polynomial $p:\mathbb{N} \to \mathbb{N}$.
We build a deterministic decider for $A$. Define $M_A$ as follows: on input $x \in \Sigma^*$, run $M_f$ to compute $f(x)$, then run $M_B$ on the computed word $f(x)$, and accept exactly when $M_B$ accepts. The correctness follows from the reduction equivalence:
\begin{align*}
M_A \text{ accepts } x \iff M_B \text{ accepts } f(x) \iff f(x) \in B \iff x \in A.
\end{align*}
It remains to check the running time. The computation of $f(x)$ takes at most $p(|x|)$ steps. During those steps, the machine can write only polynomially many symbols, so there is a polynomial $r:\mathbb{N} \to \mathbb{N}$ such that $|f(x)| \le r(|x|)$ for all $x \in \Sigma^*$. The second stage takes at most $q(|f(x)|)$ steps, hence at most $q(r(|x|))$ steps. Since a composition of polynomials is a polynomial, the total running time is bounded by
\begin{align*}
p(|x|) + q(r(|x|)).
\end{align*}
This is polynomial in $|x|$. Therefore $M_A$ is a polynomial-time deterministic decider for $A$, so $A \in \mathrm{P}$.
[/guided]
[/step]
[step:Conclude that every language in $\mathrm{NP}$ lies in $\mathrm{P}$]
The language $A \in \mathrm{NP}$ in the previous step was arbitrary. Hence
\begin{align*}
\mathrm{NP} \subseteq \mathrm{P}.
\end{align*}
[/step]
[step:Verify the reverse containment and finish the equivalence]
We prove $\mathrm{P} \subseteq \mathrm{NP}$ directly from the verifier definition of $\mathrm{NP}$. Let $C \subseteq \Sigma^*$ be a language with $C \in \mathrm{P}$. Then there exists a deterministic polynomial-time decider $M_C$ for $C$. Define a polynomial-time verifier $V_C$ that, on input pair $(x,w) \in \Sigma^* \times \Sigma^*$, ignores the certificate word $w$ and simulates $M_C$ on $x$. Then $x \in C$ if and only if there exists a certificate $w \in \Sigma^*$ such that $V_C$ accepts $(x,w)$; for example, one may take $w$ to be the empty word. Thus $C \in \mathrm{NP}$, and since $C$ was arbitrary,
\begin{align*}
\mathrm{P} \subseteq \mathrm{NP}.
\end{align*}
Combining this containment with $\mathrm{NP} \subseteq \mathrm{P}$ gives $\mathrm{P}=\mathrm{NP}$. Therefore $B \in \mathrm{P}$ implies $\mathrm{P}=\mathrm{NP}$, and together with the forward implication this proves
\begin{align*}
B \in \mathrm{P} \iff \mathrm{P}=\mathrm{NP}.
\end{align*}
[/step]