The reason you stop contributing to your 401(k) while you pay off your debt is if the interest on the debt is higher than the average returns from the stock market.
Most credit cards have interest rate of 22%. Which is higher than the average return for the S&P500.
However, if your interest is less than 5% or whatever, then it makes sense to contribute to the 401k and pay off the debt.
By the way, you need to make sure that the interest on ALL the debt you pay is lower than the return on your investments. This is something that people usually forget when they’re determining if they should invest or not. If you have a mortgage and a car loan, of a credit card debt, then you’re probably better off paying off the debt.
(If you have a match, though, then the math may work out differently. It depends on how much the match is and what’s the interest on your debts)