Simple explanation is that they have a means of evaluating the value of a given position and can calculate (and evaluate) very quickly a tree of the positions that can be reached from the current one by any sequence of legal moves and choose the line that allows them to arrive at the most favourable position.
There are a number of techniques that refine and improve the efficiency of this process, like pruning, but in a nutshell that's the process.
Inside each computer box is a small chess playing midget who is around master strength.
The midget isn't good enough to beat most professional players, but he's good enough to fool most amateurs, so he continues to sell.
Source: http://en.wikipedia.org/wiki/The_Turk