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?