The idea is that the world economy is closed and value only comes from production. It is maybe best to forget about money for a moment here. Since money derives its value directly from production, anything we say about production applies to money as well.
Since the world economy is closed a country that is producing less than it consumes must "borrow goods" from other countries to consume (otherwise it cannot consume more than it produces by definition). We can't have the whole world consuming more than it produces, so someone else must be consuming less, i.e. "lends". This is the case of a trade deficit, i.e. positive net imports. If a country "borrow goods" it effective also borrows money.
A currency's value (purchasing power) is proportionate to the number of goods in that economy, since all money must be able to buy all goods by definition and legally. (If only 1 loaf of bread and only 1 dollar exist, the dollar has a purchasing power of 1. If (only) 2 dollars exist then each dollar has a purchasing power of 0.5).
How this may work is that the exporting country lends money to the importing country in order to be able to buy more than it sells. In a barter economy this happens directly without money, the extra goods given are loans (as goods in equal value have not been receieved). Since money is not "real" in an economic sense, the same must happen with money. This happens, since each currency's value is related to production and the importing country is producing less (as it doesn't have enough to spare), while the exporting country is producing more (it has more than enough), therefore the respective currency values reflect this.
Very often an importing company will take out a credit from the exporting company and this reflects itself at the country level. Even if money isn't actually lent, it happens through adjustment in exchange rates and interest rates.
Since money's value depends on production value, this is also the reason the current acount + the capital account must be equal to 0. For any goods bought or sold, money must be paid. Its like saying the value of goods you receive at the store must equal the value of money you give to the cashier. If you get more goods than you have money for you'll simply owe the cashier. Internationally (but alson domestically) you only have money in value of what you produce. Therefore if you produce less than you consume, you don't have enough money (production=money) to pay the cashier for the goods you consume.
Further, the current account is constructed similarly as an account from accounting. It sums up to 0 by (that) construction. Goods leave, money enters, they must have the same value. For more on this you can also consult any introductory accounting book.