Logarithm and absolute value $$y' - y \tan x = 2x \sec x,\quad y(0)=0\tag1$$
integrating factor $= e^{-\int \tan x\ dx} = e^{\ln|\cos x|} = \cos x$
Can we write $|\cos x|$ as $\cos x$ above?
$$I.F. y = \int I.F.\ 2x\ \sec x\ dx\\(\cos x) y = \int \cos x \ 2x\ \sec x\ dx = \int 2x\ dx$$
If we had taken the integrating factor to be $ |\cos x|$, then in the above line $|\cos x|$ and $\sec x$ wouldn't have cancelled.

Alternative : $\begin{align}&y' - y \tan x = 2x \sec x\\&y'\cos x-y\sin x=2x\\&(y\cos x) '=2x\\&y\cos x=x^2+C\end{align}$
$y(0) =0\implies C=0$
Hence solution : $y(x)=x^2 \sec x$
