First, recall that the bijection between $H^2(Y)$ and $[Y,\mathbb{C}P^\infty]$ is obtained by pulling back the canonical generator of $H^2(\mathbb{C}P^\infty)$ and that the inclusion $S^2\rightarrow \mathbb{C}P^\infty$ pulls back the generator of $H^2(\mathbb{C}P^\infty)$ to the generator of $H^2(S^2)$. Hence, $[g]$ is really just shorthand for $g^\ast (z)$ where $z\in H^2(S^2)$ is a generator.
Likewise, $[g']$ is really just shorthand for $(f\times g)^\ast \pi^\ast(z)$
(I'm being a bit sloppy with the notion of "the" generator, but as long as you are consistent, the choice doesn't matter.)
So, the claim is that $(f\times g)^\ast \pi^\ast(z) = g^\ast(z) + f^\ast(w)$ where $z\in H^2(S^2)$ generates and $w\in H^2(SO(3))$ generates.
Claim 1: $\pi^\ast z = w + z \in H^2(SO(3)\times S^2)\cong H^2(SO(3))\oplus H^2(S^2)$
Proof: We can write $\pi^\ast z = aw+bz$ where $a\in \mathbb{Z}/2$ and $b\in\mathbb{Z}$. To determine $a$, notice the map $s:SO(3)\rightarrow S^2$ given by $A\mapsto An$ where $n$ is the north pole factors through $SO(3)\times S^2$. It follows that $s^\ast(z) = aw$. Further, the map $s$ is a fiber bundle with fiber $S^1$ as it comes from the natural group action $S^1\rightarrow SO(3)\rightarrow SO(3)/S^1 \cong S^2$.
If $a = 0$, then the map $s:SO(3)\rightarrow S^2$ is $0$ on $H^2$, hence by this MSE answer the map $s$ has a lift $\tilde{s}:SO(3)\rightarrow S^3$ to the Hopf fibration $p:S^3\rightarrow S^2$. This means the bundle $S^1\rightarrow SO(3)\rightarrow S^2$ is the pull back of the Hopf bundle by the identity map, which implies the bundle $S^1\rightarrow SO(3)\rightarrow S^2$ is isomorphic to the Hopf bundle. In particular $SO(3)$ and $S^3$ must then be diffeomorphic, an obvious contradiction. Hence, $a\neq 0$.
To determine $b$, follow a similar but easier process. The identity map $S^2\rightarrow S^2$ factors through $SO(3)\times S^2\rightarrow S^2$, and so $b = 1$.
Claim 2: $(f\times g)^\ast(w+z) = f^\ast w + g^\ast z$.
Proof: Almost by definition. We have $f = \pi_1\circ (f\times g)$ and $g = \pi_2\circ(f\times g)$ where $\pi_1$ and $\pi_2$ are the two projections onto $SO(3)$ and $S^2$. So, $(f\times g)^\ast w = (f\times g)^\ast(\pi_1^\ast w) = f^\ast w$ and likewise for $(f\times g)^\ast z$.
$$ $$
Finally, putting Claim 1 and Claim 2 together gives \begin{align*} [g'] &= (f\times g)^\ast(\pi^\ast(z)) \\ &= (f\times g)^\ast(w+z)\\ &= f^\ast w + g^\ast z\\ &= f^\ast w + [g] \end{align*} as claimed.