I understand that borrowing from a 401K is not a good idea. But I still want to be familiar with some of the mechanics. If someone takes out a $5,000 401K loan, is the money taken from the 401K account or is it more like a lien is placed on your 401K? I don't know what terminology to use.
I do not know the exact nature of the transactions made by companies managing 401ks. But when money is borrowed from a 401k, the borrowed amount is treated as not being in the account and is no longer invested in securities and misses out on any gains that would have been made. As payments are made, the money returns to the 401k. The interest usually paid on the loan is also paid into the 401k. So your losses as an account holder are the loan fee (if any) and whatever gains would have been made had the money been in the 401k. Take the loan at the right time, before a market plunge, and you will come out better off.
So, money in the 401k is not collateral for a loan, but is the source of funds for the a loan.
Borrowing from a 401k not being a good idea as you said is mostly hype if you're going to borrow money anyways. One reason: better to borrow from your 401k and pocket the interest rather than pay a higher rate of interest to a third party. Borrowing for new counter-tops or a new Audi is probably a bad idea though. Long term loans should probably be avoided also.
Source: one of my old 401k plan summaries
Additional, 3rd party source:
I think, in a way, it is both.
It is the source of the funds, in the sense that when you borrow, those funds are not available to invest on things; in effect, they are "invested" in the loan to yourself.
It is also kind of like collateral, because if you default on the loan, then it counts as if you made a withdrawal of that amount from your 401k (along with all of the consequences of withdrawal which may apply, like early-withdrawal penalty).