There are at least two general ways to solve linear equations $Ax=b$.
- First approach: compute $A^{-1}$ using Gauss-Jordan method, then $x=A^{-1}b$.
- Second approach: compute the triangular factorization $A=LU$, then solve $Lc=b$ and $Ux=c$ respectively.
Which is more preferred and why?
You didn't specify how to compute $A^{-1}$ in the first option, so the comparison isn't really possible.
A common way is by solving $AA'=I$, which gives $A'=A^{-1}$. This is certainly a very inefficient method, because it amounts to solving $n$ systems of $n$ equations in $n$ unknowns, when you initially wanted to solve a single one.
If you need to solve a single system, $LU$ factorization is unnecessary, use pure Gaussian elimination (though the only difference lies in the storage of the coefficients).
The most important: use partial or total pivoting.