[proofplan]
We decide $A$ by first computing the many-one reduction $f(x)$ and then running a polynomial-time decider for $B$ on the reduced instance. The equivalence in the definition of the reduction gives correctness. The only point requiring verification is the running time: a polynomial-time transducer cannot output more than polynomially many symbols, so feeding its output into the polynomial-time decider for $B$ still gives a polynomial bound.
[/proofplan]
[step:Choose machines and polynomial time bounds for the reduction and for $B$]
Since $A \le_m^p B$, choose a deterministic polynomial-time transducer $M_f$ computing a function $f: \{0,1\}^* \to \{0,1\}^*$ such that, for every $x \in \{0,1\}^*$,
\begin{align*}
x \in A \iff f(x) \in B.
\end{align*}
Choose a polynomial $p: \mathbb{N} \to \mathbb{N}$ such that $M_f$ halts on every input $x$ within $p(|x|)$ steps.
Since $B \in \mathrm{P}$, choose a deterministic Turing machine $M_B$ deciding $B$ and a polynomial $q: \mathbb{N} \to \mathbb{N}$ such that $M_B$ halts on every input $y \in \{0,1\}^*$ within $q(|y|)$ steps.
[/step]
[step:Build the decider for $A$ by composing the reduction with the decider for $B$]
Define a deterministic Turing machine $M_A$ as follows. On input $x \in \{0,1\}^*$, the machine $M_A$ runs $M_f$ on $x$ to compute the string $f(x) \in \{0,1\}^*$, then runs $M_B$ on input $f(x)$, and finally accepts exactly when $M_B$ accepts.
For every $x \in \{0,1\}^*$, correctness follows from the reduction equivalence:
\begin{align*}
M_A \text{ accepts } x \iff M_B \text{ accepts } f(x).
\end{align*}
Because $M_B$ decides $B$, this is equivalent to
\begin{align*}
f(x) \in B.
\end{align*}
By the defining property of $f$, this is equivalent to
\begin{align*}
x \in A.
\end{align*}
Thus $M_A$ decides $A$.
[guided]
We construct the decider for $A$ by using the reduction as a preprocessing step. Define a deterministic Turing machine $M_A$ as follows: on input $x \in \{0,1\}^*$, first run the transducer $M_f$ on $x$ and let its output be the string $f(x) \in \{0,1\}^*$. Then run the decider $M_B$ on input $f(x)$. The machine $M_A$ accepts $x$ exactly when $M_B$ accepts $f(x)$.
We now verify that this machine decides the correct language. Let $x \in \{0,1\}^*$ be arbitrary. By the definition of $M_A$,
\begin{align*}
M_A \text{ accepts } x \iff M_B \text{ accepts } f(x).
\end{align*}
Since $M_B$ decides $B$, the right-hand side is equivalent to
\begin{align*}
f(x) \in B.
\end{align*}
Since $f$ is a many-one reduction from $A$ to $B$, we have
\begin{align*}
f(x) \in B \iff x \in A.
\end{align*}
Combining these equivalences gives
\begin{align*}
M_A \text{ accepts } x \iff x \in A.
\end{align*}
Because $x$ was arbitrary, $M_A$ decides $A$.
[/guided]
[/step]
[step:Bound the running time by a polynomial]
Let $x \in \{0,1\}^*$ and define $n := |x|$. The first stage, running $M_f$ on $x$, takes at most $p(n)$ steps. Since a transducer can write at most one output symbol per computation step, the output length satisfies
\begin{align*}
|f(x)| \leq p(n).
\end{align*}
The second stage, running $M_B$ on $f(x)$, therefore takes at most
\begin{align*}
q(|f(x)|) \leq q(p(n))
\end{align*}
steps after replacing $q$ by a nondecreasing polynomial upper bound if necessary.
Define the polynomial $r: \mathbb{N} \to \mathbb{N}$ by
\begin{align*}
r(n) := p(n) + q(p(n)) + 1.
\end{align*}
Then $M_A$ halts on every input $x$ of length $n$ within $r(n)$ steps, up to the fixed one-step accept-or-reject overhead included in the definition of $r$. Hence $M_A$ is a polynomial-time decider for $A$.
[/step]
[step:Conclude that $A$ belongs to $\mathrm{P}$]
We have constructed a deterministic Turing machine $M_A$ that decides $A$ and runs in time bounded by the polynomial $r$. By the definition of the class $\mathrm{P}$, this proves $A \in \mathrm{P}$.
[/step]