[guided]Fix a subset $G \subseteq \mathbb{P}$. The point of the rank condition on names is that a name is built only from earlier names. More precisely, define $\operatorname{rank}_{\mathbb{P}}(\tau)$ to be the least ordinal strictly larger than $\operatorname{rank}_{\mathbb{P}}(\sigma)$ whenever $(\sigma,p)\in\tau$ for some $p\in\mathbb{P}$. Why does this ordinal exist? Since $\tau$ is a set, Replacement gives the set of predecessor ranks
\begin{align*}
R_\tau:=\{\operatorname{rank}_{\mathbb{P}}(\sigma): \exists p\in\mathbb{P} \text{ such that }(\sigma,p)\in\tau\}.
\end{align*}
The ordinal $\sup R_\tau+1$ is strictly larger than every ordinal in $R_\tau$, and the least such ordinal exists by well-ordering of the ordinals. Therefore, if we are evaluating $\tau$, every name $\sigma$ appearing inside $\tau$ has already appeared at a strictly lower rank.
We now use class recursion on the well-founded class relation $\sigma\prec\tau$, where $\sigma\prec\tau$ means that $(\sigma,p)\in\tau$ for some $p\in\mathbb{P}$. This relation is well-founded because every predecessor has strictly smaller name-rank:
\begin{align*}
\sigma\prec\tau \implies \operatorname{rank}_{\mathbb{P}}(\sigma)<\operatorname{rank}_{\mathbb{P}}(\tau).
\end{align*}
The recursion is a class recursion, not a set recursion, because the collection of all $\mathbb{P}$-names is generally a proper class. The recursion principle permits us to define a class assignment $E_G$ as long as the value at $\tau$ depends only on values at predecessors of $\tau$.
Assume inductively that $E_G(\sigma)$ has already been defined for every $\mathbb{P}$-name $\sigma$ satisfying
\begin{align*}
\operatorname{rank}_{\mathbb{P}}(\sigma)<\operatorname{rank}_{\mathbb{P}}(\tau).
\end{align*}
Now take any pair $(\sigma,p)\in\tau$. Since $\tau$ is a $\mathbb{P}$-name, $\sigma$ is itself a $\mathbb{P}$-name and $p\in\mathbb{P}$. By the definition of name-rank,
\begin{align*}
\operatorname{rank}_{\mathbb{P}}(\sigma)<\operatorname{rank}_{\mathbb{P}}(\tau).
\end{align*}
Hence $E_G(\sigma)$ is already available before we define $E_G(\tau)$.
We now define
\begin{align*}
E_G(\tau):=\{E_G(\sigma): \exists p\in G \text{ such that }(\sigma,p)\in\tau\}.
\end{align*}
This formula defines a set, not merely a class. Indeed, $\tau$ is a set, so Separation gives the set
\begin{align*}
A_\tau:=\{(\sigma,p)\in\tau:p\in G\}.
\end{align*}
On this set, the assignment $(\sigma,p)\mapsto E_G(\sigma)$ is already defined by the induction hypothesis. Replacement therefore gives the image set
\begin{align*}
\{E_G(\sigma):(\sigma,p)\in A_\tau\},
\end{align*}
which is exactly
\begin{align*}
\{E_G(\sigma): \exists p\in G \text{ such that }(\sigma,p)\in\tau\}.
\end{align*}
Thus the recursive clause produces a legitimate set at the stage $\tau$.[/guided]