The takeaway is that the three classes $w_1$, $w_2$, and $\frac{1}{2}p_1$ are generators for their corresponding cohomology groups. This is the property one needs so that the homotopy fiber is the next stage of the Whitehead tower of $BO$.

The Whitehead tower of a connected CW complex $X$ is a tower of connected CW complexes $\cdots \to X\langle3\rangle \to X\langle 2\rangle \to X\langle 1\rangle \to X$ where

$\pi_i(X\langle n\rangle) = 0$ for $i = 0, 1, \dots, n-1$,

the induced map $X\langle n\rangle \to X$ induces an isomorphism of $\pi_i$ for $i \geq n$, and

the maps $X\langle n+1\rangle \to X\langle n\rangle$ are fibrations with fiber $K(\pi_n(X), n-1)$.

By attaching cells of dimension at least $n + 2$, one can form a $K(\pi_n(X\langle n\rangle), n)$ which has $X\langle n\rangle$ as a subcomplex. Note that $\pi_n(X\langle n\rangle) \cong \pi_n(X)$ so we have an inclusion $\alpha_n : X\langle n\rangle \hookrightarrow K(\pi_n(X), n)$. Since $\alpha_n$ induces an isomorphism on $\pi_n$, it follows that the pullback of the pathspace fibration

$$\begin{array}{ccc}
\Omega K(\pi_n(X), n) = K(\pi_n(X), n-1) & \longrightarrow & PK(\pi_n(X), n)\\
& & \Big\downarrow\\
& & K(\pi_n(X), n)
\end{array}$$

is $X\langle n+1\rangle \to X\langle n\rangle$, so $\alpha_n$ is a classifying map for $X\langle n+1\rangle \to X\langle n\rangle$; note that $K(\pi_n(X), n) = BK(\pi_n(X), n-1)$. Alternatively, $X\langle n+1\rangle \to X\langle n\rangle$ is the homotopy fiber of $\alpha_n : X\langle n\rangle \to K(\pi_n(X), n)$.

So $X\langle n+1\rangle \to X\langle n\rangle$ is determined by $\alpha_n \in [X\langle n\rangle, K(\pi_n(X), n)] \cong H^n(X\langle n\rangle; \pi_n(X))$. Note that by the Hurewicz and Universal Coefficient Theorems, we have

$$\begin{align*}
H^n(X\langle n\rangle; \pi_n(X)) &\cong \operatorname{Hom}_{\mathbb{Z}}(H_n(X\langle n\rangle; \mathbb{Z}), \pi_n(X))\\
&\cong \operatorname{Hom}_{\mathbb{Z}}(\pi_n(X\langle n\rangle), \pi_n(X))\\
&\cong \operatorname{Hom}_{\mathbb{Z}}(\pi_n(X), \pi_n(X)).
\end{align*}$$

If $\pi_n(X)$ is cyclic, then $\operatorname{Hom}_{\mathbb{Z}}(\pi_n(X), \pi_n(X)) \cong \pi_n(X)$. Under this correspondence, isomorphisms $\pi_n(X) \to \pi_n(X)$ correspond to generators of $\pi_n(X)$. In particular, since $\alpha_n : X\langle n\rangle \to K(\pi_n(X), n)$ induces an isomorphism on $\pi_n$, it follows that $\alpha_n \in H^n(X\langle n\rangle; \pi_n(X)) \cong \pi_n(X)$ is a generator. One can show that different choices of generator correspond to the same fibration $X\langle n+1\rangle \to X\langle n\rangle$ up to homotopy.

By Bott periodicity, we know the homotopy groups of $BO$ (note, they are always cyclic). Suppressing the stages where the homotopy groups are zero, we have

$$\require{AMScd}
\begin{CD}
\vdots\\
@VVV\\
BO\langle 8\rangle = BString @>{\alpha_8}>> K(\mathbb{Z}, 8) = B^8\mathbb{Z}\\
@VVV\\
BO\langle 4\rangle = BSpin @>{\alpha_4}>> K(\mathbb{Z}, 4) = B^4\mathbb{Z}\\
@VVV\\
BO\langle 2\rangle = BSO @>{\alpha_2}>> K(\mathbb{Z}_2, 2) = B^2\mathbb{Z}_2\\
@VVV\\
BO @>{\alpha_1}>> K(\mathbb{Z}_2, 1) = B\mathbb{Z}_2
\end{CD}$$

Since $H^1(BO; \mathbb{Z}_2) = \{0, w_1\}$ and $H^2(BSO; \mathbb{Z}_2) = \{0, w_2\}$, we see that $\alpha_1 = w_1$ and $\alpha_2 = w_2$ respectively. The next case is not as immediate.

First note that the pullback of $p_1$ to $H^4(BSpin; \mathbb{Z})$ is non-zero, but as you point out in the comments, it satisfies $p_1\equiv w_2^2 \bmod 2$ and hence $p_1$ is divisible by $2$ in $H^4(BSpin; \mathbb{Z})$. Since $BSpin$ is 3-connected with $\pi_4(BSpin) \cong \mathbb{Z}$, we have $H^4(BSpin; \mathbb{Z}) \cong \mathbb{Z}$, so there is a unique element $\frac{1}{2}p_1$ satisfying $2\left(\frac{1}{2}p_1\right) = p_1$. One can show that $\frac{1}{2}p_1$ generates $H^4(BSpin; \mathbb{Z})$ by either computing the Serre spectral sequence for the fibration $K(\mathbb{Z}_2, 1) \to BSpin \to BSO$, or by considering a specific example such as $\mathbb{HP}^2$ whose $p_1$ is twice a generator of $H^4(\mathbb{HP}^2; \mathbb{Z})$ - see this question for more details. Therefore $\alpha_4 = \frac{1}{2}p_1$. Similarly, one can show that $H^8(BString; \mathbb{Z}) \cong \mathbb{Z}$ is generated by $\frac{1}{6}p_2$, so $\alpha_8 = \frac{1}{6}p_2$ - see Proposition 1 in section 4.5 of this paper.

1more comment