$$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.
The solution is
$$y|\cos x|=\int 2x \sec x \times|\cos x|\, dx+c, c\in\mathbb R$$
$\implies y\times (\pm \cos x)=\pm\int 2x \sec x \times \cos x \, dx+c$
$\implies y=\pm\dfrac{ x^2}{(\pm \cos x)}\pm c \sec x$
$\implies y=x^2 \sec x +c \sec x, c\in\mathbb R$