Let $r:X\to A$ be the retract which induces an epimorphism $r_*:\pi_1(X,x_0)\to\pi_1(A,x_0)$ and let $i:A\to X$ be the inclusion which induces an monomorphism $i_*\pi_1(A,x_0)\to \pi_1(X,x_0)$. Then, you can apply the first isomorphism theorem to conclude that $\pi_1(A,x_0)\cong \pi_1(X,x_0)/ker(r_*)$ (isomorphic to a quotient). So if you rewrite the RHS of the expression,
$$\pi_1(A)\times\pi_1(X)/\pi_1(A)\cong\pi_1(A)\times\pi_1(X)/(\pi_1(X)/ker(r_*))\cong\pi_1(A)\times ker(r_*)$$
Then it's pure algebraic process, see here or here (where you need to use the condition that $\pi_1(A)$ is normal).
To calculate the fundamental group for klein bottle ($K$) using the method in you book would be the following.
Choose an open square called $U$, homeomorphic with an open disk which is simply connected, just like the follwing picture.
Then choose $V=K\setminus I^2$ which is equivalent to this bigger square minus a square smaller than $U$ so that $U\cap V\neq\varnothing$.
it's easy to see that $\pi_1(U,x_0)\cong\{1\}$. For $V$, it can be deformation retract to the square (outer boundary), so $\pi_1(V,x_0)\cong\Bbb{Z}\times\Bbb{Z}$
It's easy to see that $\pi_1(U\cap V,x_0)\cong\Bbb{Z}$ since $U\cap V\simeq S^1$. Let $j:\pi_1(U\cap V)\to \pi_1(V)$, and then $N=\text{Im }j_*=<aba^{-1}b>$ and hence $\pi_1(K,x_0)\cong \pi_1(V,x_0)/N=<a,b|aba^{-1}b=1>$ by applying Van Kampen's Thm.
To show $K$ doesn't retract onto $b$ (call the space $B$), we, first, try to show it's normal:
$$\pi_1(B)=<b>=\{b^m|m\in\Bbb{Z}\}\cong\Bbb{Z}$$
and
$$aba^{-1}b=1\implies aba^{-1}=b^{-1}\in \pi_1(B)$$
which implies $\pi_1(B)$ is normal.
Next, assume $K$ does retract onto $b$ then $\pi_1(X)\cong\Bbb{Z}(b)\times(\Bbb{Z}^2(a,b)/aba^{-1}b)/\Bbb{Z}(b)$, but we reach to a contradiction since the RHS is the product of a group with 1 generator and an infinite cyclic group.
Let $r:X\to A$ be the retract which induces an epimorphism $r_*:\pi_1(X,x_0)\to\pi_1(A,x_0)$ and let $i:A\to X$ be the inclusion which induces an monomorphism $i_*\pi_1(A,x_0)\to \pi_1(X,x_0)$. Then, you can apply the first isomorphism theorem to conclude that $\pi_1(A,x_0)\cong \pi_1(X,x_0)/ker(r_*)$ (isomorphic to a quotient). So if you rewrite the RHS of the expression, $$\pi_1(A)\times\pi_1(X)/\pi_1(A)\cong\pi_1(A)\times\pi_1(X)/(\pi_1(X)/ker(r_*))\cong\pi_1(A)\times ker(r_*)$$
Then it's pure algebraic process, see here or here (where you need to use the condition that $\pi_1(A)$ is normal).
To calculate the fundamental group for klein bottle ($K$) using the method in you book would be the following.
Choose an open square called $U$, homeomorphic with an open disk which is simply connected, just like the follwing picture.
Then choose $V=K\setminus I^2$ which is equivalent to this bigger square minus a square smaller than $U$ so that $U\cap V\neq\varnothing$.
it's easy to see that $\pi_1(U,x_0)\cong\{1\}$. For $V$, it can be deformation retract to the square (outer boundary), so $\pi_1(V,x_0)\cong\Bbb{Z}\times\Bbb{Z}$
It's easy to see that $\pi_1(U\cap V,x_0)\cong\Bbb{Z}$ since $U\cap V\simeq S^1$. Let $j:\pi_1(U\cap V)\to \pi_1(V)$, and then $N=\text{Im }j_*=<aba^{-1}b>$ and hence $\pi_1(K,x_0)\cong \pi_1(V,x_0)/N=<a,b|aba^{-1}b=1>$ by applying Van Kampen's Thm.
To show $K$ doesn't retract onto $b$ (call the space $B$), we, first, try to show it's normal: $$\pi_1(B)=<b>=\{b^m|m\in\Bbb{Z}\}\cong\Bbb{Z}$$ and $$aba^{-1}b=1\implies aba^{-1}=b^{-1}\in \pi_1(B)$$ which implies $\pi_1(B)$ is normal.
Next, assume $K$ does retract onto $b$ then $\pi_1(X)\cong\Bbb{Z}(b)\times(\Bbb{Z}^2(a,b)/aba^{-1}b)/\Bbb{Z}(b)$, but we reach to a contradiction since the RHS is the product of a group with 1 generator and an infinite cyclic group.