method 1:Substitution
$\int \sec x\tan x dx=\int \frac{\sin x}{\cos ^2x}dx$
Let $u=\cos x \implies -du=\sin x dx$
$-\int \frac{1}{u^2}du=\frac{1}{u}+c$
So $\int \sec x\tan x dx=\frac{1}{\cos x}=\sec x+c$
Method 2:integration by parts
$\int \sec x\tan x dx=\int \sec ^2x\sin xdx$
Let $u=\sin x$ and $dv=\sec^2x dx \implies du=\cos x dx$ and $v=\tan x$
$\int \sec ^2x\sin xdx=\tan x \sin x-\int \tan x\cos x dx$
$=\tan x \sin x-\int \sin x dx$
$=\tan x \sin x+\cos x +c$
I cannot tell where I went wrong especially with the second method.
Nothing went wrong. Just note that\begin{align}\tan(x)\sin(x)+\cos(x)&=\frac{\sin^2(x)}{\cos(x)}+\frac{\cos^2(x)}{\cos(x)}\\&=\frac1{\cos(x)}\\&=\sec(x).\end{align}