It just really depends on the situation. If you lease, sometimes you pay up front for it. For example, when my wife leased her Highlander there was a $400 gap insurance fee.
Other brands will roll it into the costs of the lease.
Some make you take out your own coverage. When you do that, sometimes it is in it's own policy and you get billed seperate, other times it's rolled into your "basic" insurance.
It just really depends on the purchase agreement. Some companies won't let you lease without it. If you purchase and drive a $25,000 domestic car off the lot and end up totaling it down the street, your insurance company isn't going to pay you $25,000. They are going to give you the whole sale cost of that car. Which is around $16,000.
That's $9,0000 that you would be upside down on if you did a zero down loan. Gap insurance covers that "gap" between wholesale and what you owe on the car.