$$ \int \cos 2x\,dx $$
simplifies to $$ \frac{1}{2} \int \cos u \, du$$ where $u = 2x$
My Question is where does the $1/2$ that is factored out come from?
It would make more sense for a factor of $1/2$ to be extracted if the integral was: $$ \int \frac{\cos x} 2 \, dx$$
When you do a $u$-substitution, you have to substitute for every $x$ in the integral, including the $dx$. Starting from $u=2x$, you can differentiate both sides and get $\frac{du}{dx}=2$. We rewrite this as $\frac12 du=dx$.
Thus, when you substitute in the integral, you replace the $2x$ with a simple $u$, and you replace the $dx$ with $\frac12 du$. We write the $\frac12$ out in front of the integral, and then we proceed with our simpler integral in terms of $u$.