When does a vector component keep being a vector, exactly?
First of all, an expression like $$dE_{x} = d\vec{E}\,\cos\theta$$ can never be correct. If you have a vector on the right, you will also have a vector on the left. The correct expression would be $$dE_{x} = d\vec{E} \cdot \hat{u}_x = \frac{dq}{4\pi\epsilon_{0}r^{2}} \underbrace{(\hat{u} \cdot\hat{u}_x)}_{\cos\theta} = \frac{dq}{4\pi\epsilon_{0}r^{2}} \cos\theta$$ which is indeed a scaler ("just a number", as you call it).
What is happening here is that we want to know the electric field vector $$ \vec{E} = \begin{pmatrix} E_x \\ E_y \\ E_z \end{pmatrix}. $$ However, we know from symmetry, that two of these entries must be zero. $$ \vec{E} = \begin{pmatrix} E_x \\ 0 \\ 0 \end{pmatrix}. $$ Now, because we already know which direction the field is pointing (along the $x$-axis), we only need to calculate the magnitude of $E_x$ to get our result. So we extract the scalar $E_x$ from the vector like this: $$ E_x = \hat{u}_x \cdot \vec{E} = \begin{pmatrix} 1 \\ 0 \\ 0 \end{pmatrix}\cdot\begin{pmatrix} E_x \\ E_y \\ E_z \end{pmatrix}$$ Now we want to know the contribution of a line element to the total field, which you have already given $$d\vec{E} = \frac{dq}{4\pi\epsilon_{0}r^{2}}\hat{u}$$ But we only need the $x$-component, which is the projection of $d\vec{E}$ onto the $x$-axis, which is already given above $$dE_{x} = d\vec{E} \cdot \hat{u}_x = \frac{dq}{4\pi\epsilon_{0}r^{2}} \cos\theta$$ from the geometry of the problem.
Then calculation for $E_x$ continues as in your post. However, in the end we want the electric field vector, so we need to substitute the magnitude of $E_x$ back into a vector that has only an $x$-component. $$\vec{E} = \begin{pmatrix} E_x \\ 0 \\ 0 \end{pmatrix} = E_x \cdot \begin{pmatrix} 1 \\ 0 \\ 0 \end{pmatrix} = E_x \cdot \hat{u}_x$$
You cannot have a scalar equal to a vector.
Starting from $d\vec{E} = \dfrac{dq}{4\pi\epsilon_{0}r^{2}}\hat{u}$ to get to the componet in the $\hat x$ direction
$d\vec{E} \cdot \hat x = dE_{\rm x} = \dfrac{dq}{4\pi\epsilon_{0}r^{2}}\hat{u} \cdot \hat x =\dfrac{dq}{4\pi\epsilon_{0}r^{2}} \cos \theta$
A vector's component is also a vector. If we have a vector $\vec{v}$ in (for example) two dimensions, we can say that it is the sum of two components, which are its projections on the $x$-axis and $y$-axis. Mathematically:
$$\vec{v} = \vec{v}_x + \vec{v}_y$$
In the problem you are solving:
$$d\vec{E} = d\vec{E}_x + d\vec{E}_y$$
This a vector sum, of course. A vector's component is still a vector, it is not a scalar. If we want to talk about the modulus of the vectors however:
$$dE^2 = dE_x^2 + dE_y^2$$
We may also write this in terms of the angles. We would find:
$$dE_x = dE \cos\theta$$ $$dE_y = dE \sin\theta$$
So a vector is never equal to a scalar.