[guided]The point of the size calculation is that the iteration is long enough to handle $\kappa$ many forcing problems, but not so large that it creates more than $\kappa$ many names for reals. We use the standard size lemma for finite-support iterations. The hypotheses of that lemma are exactly the present ones: the length is $\kappa$, the cardinal $\kappa$ is regular, $M\models\kappa^{<\kappa}=\kappa$, and each $\mathbb P_\alpha$ forces $|\dot{\mathbb Q}_\alpha|<\kappa$.
Here is the coding behind the lemma. For each $\alpha<\kappa$, choose in $M$ a $\mathbb P_\alpha$-name $\dot e_\alpha$ and an ordinal $\mu_\alpha<\kappa$ such that $\mathbb P_\alpha$ forces that $\dot e_\alpha:\mu_\alpha\to\dot{\mathbb Q}_\alpha$ is surjective. A finite-support condition $p\in\mathbb P_\gamma$ is determined by its finite support $\operatorname{supp}(p)\subseteq\gamma$ and, for each $\alpha\in\operatorname{supp}(p)$, by a $\mathbb P_\alpha$-name for a condition in $\dot{\mathbb Q}_\alpha$. Using $\dot e_\alpha$, every such coordinate name can be replaced by a name for an ordinal below $\mu_\alpha$, together with the earlier forcing information that decides enough of that ordinal-name to define the coordinate. By the inductive hypothesis, the earlier forcing has size $<\kappa$ at proper stages and size at most $\kappa$ at the endpoint, so the number of possible earlier pieces of deciding information is bounded by $\kappa$.
Now induct on $\gamma\leq\kappa$. A condition in $\mathbb P_\gamma$ has finite support contained in $\gamma$. For each coordinate in that finite support, the possible coded coordinate data has size at most $\kappa$, and at proper stages below $\kappa$ it has size $<\kappa$. Therefore the set of all codes for conditions in $\mathbb P_\gamma$ injects into the set of finite sequences drawn from $\gamma\times\kappa$. If $\gamma\leq\kappa$, this has size at most $\kappa^{<\omega}\leq\kappa^{<\kappa}=\kappa$. Hence $|\mathbb P_\kappa|\leq\kappa$.
For a proper initial segment $\gamma<\kappa$, the same induction gives the sharper estimate $|\mathbb P_\gamma|<\kappa$. Indeed, all supports are finite subsets of $\gamma$, there are fewer than $\kappa$ possible finite supports, and for each fixed finite support the coordinate data is drawn from fewer than $\kappa$ many possibilities; regularity of $\kappa$ ensures that the union of fewer than $\kappa$ many sets of size $<\kappa$ still has size $<\kappa$. Finally, let $S\subseteq\kappa$ be the set of stages at which Cohen forcing is scheduled, so $|S|=\kappa$. For each $\beta\in S$, form the condition $p_\beta$ whose support is $\{\beta\}$, whose $\beta$-coordinate is the Cohen condition deciding the first bit to be $1$, and whose other coordinates are trivial. Distinct $\beta$ give distinct supports, hence distinct conditions. Thus $|\mathbb P_\kappa|\geq\kappa$, and therefore $|\mathbb P_\kappa|=\kappa$.[/guided]