- How does a country get so far in debt, and who is it in debt to?
Mostly because of government-issued bonds. These can be held by other governments, private entities or even the various government agencies: In the US, starting with the last category:
Intragovernmental Holdings. This is the portion of the federal debt owed to 230 other federal agencies. Intragovernmental holdings total $5.6 trillion, almost 30 percent of the debt. Why would the government owe money to itself? Some agencies, like the Social Security Trust Fund, take in more revenue from taxes than they need. Rather than stick this cash under a giant mattress, these agencies buy U.S. Treasurys with it.
Debt Held by the Public. The public holds the rest of the national debt of $14.7 trillion. Foreign governments and investors hold almost half of it.
Since I see you're from the UK... over there bonds are called gilts. And here's a breakdown of their ownership from 2009 (since that's what I could easily find):
The biggest owners of gilts are insurance companies and pension funds. For them, gilts are predictable investments, which are particularly useful when a low-risk product is needed. Pension funds, for example, will usually switch an individual's holdings from higher risk investments, such as shares in companies, and put them in gilts as the person gets closer to retirement.
Next on the list comes investors overseas. Unfortunately, nobody keeps records showing in which countries these gilts are held. This is in contrast to, for example, the US, which regularly publishes lists of the countries that own its Treasury Bills. So we know that at the end of 2009, $302.5bn (£196bn) of US government debt was held in the UK, making the UK the third-biggest investor behind Japan and China.
The next biggest category holding UK government debt is banks, which includes the Bank of England. Since March 2009, as part of its quantitative easing programme, the Bank of England has bought just short of £200bn of gilts, making it the third-biggest holder of UK government debt.
- How can countries of the world operate owing such vast amounts of money?
It depends on the country. Countries whose currency is attractive enough, e.g. the US dollar can "get away with it" by "printing" more money (see quantitative easing), although they can't do that too fast because that can cause inflation.
Countries whose debt is denominated in a foreign currency, or a currency they can't print for some other reason, e.g. being in monetary union (ahem, Greece) can be in a world of hurt if they suddenly are threatened by default (inability to pay back on schedule). Typically the IMF steps in but it also imposes conditions in terms of structural reforms etc. for their bailouts.