A peg works when a central bank has enough of the foreign currency that they can credibly offer to exchange to and from the local currency at a fixed ratio. Since the US Dollar is a huge major reserve currency around the world, most foreign central banks, particularly in countries that export to us, are able to do this, if they choose to.
Why they would want to do so is a more difficult question.
can you clarify on the "enough" part? how much?
It would be tough to put a number on that, but in general he means enough to maintain the peg. That means they have to able to sell USD to buy their domestic currency (which reduces the supply of the domestic currency and causes the value to increase), or buy USD using their domestic currency (which increases the supply of domestic currency and causes the value to go down). How much is that? Who knows. Depends how aggressively the market is trying to move the price of your currency I suppose.
Sometimes this gets messed up by whoever is running the show. That was one of the issues (among many I'm not going to type out right now) in the Asian currency crisis in 97. The central banks of a bunch of Asian countries ran out of the currency reserves they where using to maintain their exchange rates at a certain level, and everything crashed when they couldn't support the price anymore.
As for why countries do it is to tie their monetary policy decisions to the country they are pegging their currency to. When you peg to the USD for example you no longer have to make decisions about the size of your money supply, or interest rates or anything like that as long as you maintain your pegged value.
Or maybe they're just lazy.