When Jech says that $\dot f$ is a name for $f$, what he means is that the interpretation of $\dot f$ by the filter $G\times H$ is $f$. Therefore some condition $p$ in $G\times H$ forces that $\dot f$ is a function from $\check\lambda$ to the ground model $\check M$.
Other incompatible conditions might force totally different things about this particular name, but by extending $p$ to a maximal antichain and then applying the mixing lemma, we may replace $\dot f$ with another name $\dot h$, such that $p$ forces $\dot f=\dot h$, and all the other conditions in the maximal antichain force that $\dot h$ is, say, the constant zero function on $\check\lambda$. Now, every condition will force that $\dot h$ is a function from $\check\lambda$ to $\check M$, and the interpretation of $\dot h$ by $G\times H$ will agree with that of $\dot f$, since $p$ forces they are equal.
This is a very commonly used method in forcing arguments. If you have an object in the extension, then you can take a name for it, and by the mixing lemma, you can assume without loss that every condition forces that it has the property you assumed about that object, provided that you can easily manufacture names for such objects to use with the other conditions in an antichain.
Next, from $\dot h$, we can look at the possible values of $\dot h(\check\alpha)$ for $\alpha<\lambda$, meaning the objects $a$ for which there is some condition $q$ forces $\dot h(\check\alpha)=\check a$. For each $\alpha$ there are only a set of such possible values $a$ in $M$, because these are incompatible features of the function $\dot h$ and therefore the conditions must be incompatible. So if we let $A$ be the set of all such $a$ that arise, we have a set $A\in M$ such that every condition forces that $\dot h$ is a function from $\check\lambda$ to $\check A$. So we've achieved the desired situation of a name for $f$ and a set $A$ in $M$, such that every condition forces that that name is a function from $\lambda$ to $A$.