You say yourself all loans are paid with after tax dollars. So you take money out of your 401k that was deducted from your taxes, repay it with after tax funds on which you have paid taxes, then later when withdrawn you have to pay taxes on it a second time. Not a good deal!
This is flat out incorrect or no different than another loan type. You are paying after tax dollars on a loan that you paid no taxes on. This is true for a 401k loan or a HELOC or any other debt.
Here I'll give you a VERY simple example.
Let's say I have exactly $200 in my 401k and a credit card with a $100 open line and I need $100 today. I can borrow at 5% from my 401k or I can borrow at 5% from my credit card annually and I plan to pay it back after exactly one year. For the sake of this example to simplify the #s, let's say I have all of my 401k sitting in 0% interest cash and will until I retire and withdraw it. Let's also say for the sake of this example I will pay 10% in taxes in retirement on my 401k withdraw and I plan on withdrawing my entire 401k at once 20 years from now.
Option 1 - Borrow from bank
Step 1: 401k - Stays at $200 today. Bank lends me $100 and I pay no taxes on this loan. I spend $100 (net cash of $0)
Step 2: 401k still at $200 a year from now.
I pay the bank back $105 in after tax dollars on the credit card.
Step 3: Retire - Withdraw $200 in 20 years and pay 10% taxes, for a net withdraw of $180 after taxes.
Total amount in retirement after taxes: $180; Total loan repayment with interest: $105
Option 2 - Borrow from 401k
Step 1: Borrow $100 from 401k. I pay no taxes on this loan. I spend $100. 401k Balance is now $100
Step 2: In one year, I pay back 401k $105 with after tax dollars. 401k Balance is now $205.
Step 3: Retire. Withdraw $205 in 20 years and pay 10% in taxes, for a net withdraw after taxes $184.5
Total amount in retirement after taxes: $184.5; Total loan repayment with interest: $105
I'm better off in scenario 2 than scenario 1 with a total net worth increase of $4.5 after taxes as that is exactly the mechanics of the loans in both cases.
Now, it is more complicated because most people don't park their 401k investments in 0% cash so the value can go up or down in between but taxes and "double taxes" have zero to do with the decision to borrow from your 401k or some other source. All loans are paid with after tax dollars, period. Otherwise the government would count the loan as income. And your 401k will be taxed in retirement whether or not you borrow against it. This is what is known as a sunk cost, and its because you received a tax deduction for the initial entry. A 401k loan in no way changes this mechanic.