Start with borrowing money for the comparison for apples to apples. If you don’t need to borrow money, you wouldn’t borrow it from your 401K. The interest cost is coming out of your pocket no matter what. Except if you are paying yourself, it is staying in your pocket. You can either keep it or give it away. That is guaranteed.
Under your comparison you could pay someone else 10%, but typically more for an unsecured loan right now which you would need to subtract from any earnings you get from your 401K because you didn’t borrow from there. Apples to apples.
Think of the decision’s impact on your net worth, all other things being equal. Apples to apples you are earning a guaranteed 10% in your 401K loan because you would lose it if you were paying a third party. Just because you are paying it isn’t relevant to looking at what happens to your net worth versus a third party loan.
Whether you pay interest or not isn’t part of the evaluation. That is a different subject.