Why is this?
There isn't some profound reason here that dictates to do it one way or the other. The choice is really yours, and made out of convenience or preference.
I think you'd benefit from a refresher on vectors, so here goes. Any vector can be written as
$$\mathbf{v} = v_x\mathbf{\hat{x}} + v_y\mathbf{\hat{y}} + v_z\mathbf{\hat{z}}$$
where $v_x$, $v_y$ and $v_z$ (the scalar components) are just real numbers; $\mathbf{\hat{x}}$, $\mathbf{\hat y}$ and $\mathbf{\hat{z}}$ are the corresponding basis vectors - these have length 1, are axis-aligned, and are variously denoted $\{\mathbf{\hat{x}}, \mathbf{\hat{y}}, \mathbf{\hat{z}}\}$, $\{\mathbf{\hat{I}}, \mathbf{\hat{J}}, \mathbf{\hat{K}}\}$, $\{\mathbf{\hat{i}}, \mathbf{\hat{j}}, \mathbf{\hat{k}}\}$, $\{\mathbf{e_1}, \mathbf{e_2}, \mathbf{e_3}\}$, etc. You can think of $v_x\mathbf{\hat{x}}$, $v_y\mathbf{\hat y}$ and $v_z\mathbf{\hat{z}}$ as of (axis aligned) vector components of $\mathbf v$, which are just separately scaled versions of the basis vectors (each by the corresponding scalar component of $\mathbf v$).
(image source)
It's just vector addition.
Denoting the length of $\mathbf{v}$ by $v = \sqrt{v_x^2 + v_y^2 + v_z^2}$, you can also write that vector as
$$\mathbf{v} = v\mathbf{\hat{v}}$$
where $\mathbf{\hat{v}}$ is a unit vector in the same direction. The right-hand side is just a resizing of a unit-length vector to the length $v$.
This unit vector $\mathbf{\hat{v}}$ will have components proportional to the original components; namely, it's the vector:
$$\mathbf{\hat{v}} = \frac{v_x}{v}\mathbf{\hat{x}} + \frac{v_y}{v}\mathbf{\hat{y}} + \frac{v_z}{v}\mathbf{\hat{z}}$$
(x-component: $v_x/v,\ $ y-component: $v_y/v,\ $ z-component: $v_z/v$; the squares of these sum up to 1).
For a vector that lies within the x-z plane, these are just going to be
$$\mathbf{v} = v_x\mathbf{\hat{x}} + v_z\mathbf{\hat{z}}$$
and
$$\mathbf{\hat{v}} = \frac{v_x}{v}\mathbf{\hat{x}} + \frac{v_z}{v}\mathbf{\hat{z}}$$
"seems like it might have something to do with how we only need to
work with one component of E to find it in the first situation"
You're not working with a single component there. The book uses a curly r that I cannot reproduce here, so I'll use $\mathbf{\rho}$ instead. The $\mathbf{\hat\rho}$ vector has two components
$$\mathbf{\hat\rho}= \frac{\rho_x}{\rho}\mathbf{\hat{x}} + \frac{\rho_z}{\rho}\mathbf{\hat{z}}$$
where $\rho_x = -x$, and $\rho_z = z\ $ (in terms of the labels in the diagram).
So you're really taking both of them into account simultaneously. The $\mathbf{\hat{\rho}}$ unit vector is actually changing direction as you move along the x-axis, from -L to L (as it keeps pointing at $P$) - the components are each a function of position $x$, and are both changing. But you can integrate the vector components separately (split the integral) due to linearity - i.e. because it's just addition. And as the basis vectors $\mathbf{\hat{x}}$ and $\mathbf{\hat{z}}$ are constant, you can pull them out of the integral.
But that also means that you can work with the scalar components on their own, and add the appropriate basis vectors back in when you're done (as long as you keep track of which component is which). Here, due to the symmetry of the setup in the Example 2.2, it turns out that the x-component of $\mathbf{E}$ is zero.
You can either choose to work with the vector itself, or temporarily ignore the vector nature of integrand, and work with the individual scalar components separately, adding the basis vectors back in at the end to reconstruct the vector quantity.
In other words, you can use both approaches on both problems.