The loans were not "paid off" ... technically you defaulted on them so the unpaid distribution is taxable ... on the 1099-R you will see a code 1 in box 7 and unless you can put in the early distribution amount back into the 401K or an IRA by the filing deadline of the tax return there is no way to avoid the taxes or the penalty if you are under the age of 59.5.
What is the code in box 7 of the Form 1099-R? If code M is present, this was an offset distribution paying off the loan, not a default.
If code M is present in box 7 of a 2021 Form 1099-R and you filed your tax return or requested a filing extension by April 18, 2022, you have until October 17, 2022 to come up with the money and roll it over to a qualified retirement account like an IRA. Taxes will continue to be deferred on any portion of the taxable amount shown in box 2a that is rolled over and the rest of the taxable amount will be taxable on your 2021 tax return. When rolling over a portion of an offset distribution more than 60 days after the date of the distribution, you must tell the receiving custodian that it's a rollover of an offset distribution.
If code M is not present in box 7, it's too late to roll over a 2021 distribution and you are stuck with the tax and penalty assessed on your tax return.