As the other poster said, it's a special type of collateralized loan where since everything is known, it can be done automatically.
You can get approved for a margin account at TD Ameritrade right now, and then later decide to margin some shares for whatever reason. The bank doesn't need to check your collateral because it knows how much it is worth at any given moment when the market is open.
Mortgage loans are not nearly as formalized, and the bank will send out an appraiser to verify that the property is worth an amount that they're willing to loan against.
And once you get past that, it becomes very hand-wavy; banks making loans to governments, non-profits, private companies, etc will all have their internal departments that make decisions about how much the risk is and what premium they'd need to charge.
A margin loan is just a loan where securities are the collateral asset.
The major feature of a margin loan versus other types of loans collateralized by assets is that the value of the underlying security (collateral) is tracked and depending on the terms of the margin loan, the lender has the right to issue a "margin call" demanding additional collateral or cash if the underlying securities have declined in value. These rules, called "house requirements," vary from lender to lender.
Margin loans use commonly traded commodities, normally stocks. Because they are easy to value (compared to a house) and liquid they are easier to get. However, because they are easy to value, they get compared to the loan value constantly. You'll be allowed to borrow X% of the values of your shares. If they go up, you can borrow more money. If they go down, you have to immediately pay off part of that loan. Since X < 100%, you can do so by selling shares (but of course, that decreases the amount of the collateral you have again), but you could also just deposit cash or pay it another way. They normally are more than happy for you to not have to sell shares if you deposit money.
Ok that makes sense, but I thought his other loan from MS was also using his stock as collateral?
If you're MS, why would you want to treat stock as "normal" collateral instead of using a margin loan? Is that Elon only feels comfortable using so much of his stock for a margin loan, and wants to use the rest as "normal" collateral (but is then getting less favorable terms for it)?
I have no idea why MS would choose to mix-and-match. Maybe the margin department has a global limit and that's hit by giving most of it to Musk? Maybe the margin department only covers the amount of Musk's stock they think they can sell in a margin call without causing the stock to tank? Maybe the other loan was using SpaceX stock (margin would only apply to public stock)?
It's also possible that Elon is getting a lower rate for the non-margin loan, but at a much worse multiple (putting up far more shares as collateral).
a) $21 billion of Elon's ("Reporting Person"; see item #1) own money
b) $12.5 billion in margin loans arranged by Morgan Stanley
c) $13 billion in debt from Morgan Stanley