It is mathematiclly impossible to create a single technique for compressing all possible data streams. However, most useful data has redundancy. In theory, an stream of data that contains any redundant information can be compressed, though often that redundancy is present in a way that requires a special purpose algorithm. One example of redundant data in audio is correlation between left and right channels.
The basic theory behind flac and a some other lossless compressors) is the concept of a "predictor".
For each input block, a predictor is chosen for that block. A predictor is a formula that "guesses" at the next value by doing some math on the previous few values. The guess probably won't be exactly right, but it will be close. For example, a simple linear predictor might be:
p = 2*v1 - v2
or to make it more readable:
p = v1 + (v1 - v2)
Where v1 is the previous value, and v2 is the value before that. This particular predictor assumes that if the last coule values were "moving" in one direction, the current value will probably be a similar distance in the same direction. This probably won't exactly be true, but it may be close. When encoding, the difference between the actual value and the predicted value (p) is stored as in a stream of data called the residual.
The goal is to make the numbers in the residual as small as possible. The predictor chosen for the block is stored in the block header (it only takes a couple bytes). The residual, which ideally consists of much smaller numbers than the original signal, is compressed losslessly in a way you're probably more familiar with. FLAC uses rice codes (which to my understanding is basically a special case of huffman coding). More common numbers are given shorter codes, less common ones are given longer codes.
When decoding, the decoder takes the last few decoded values, runs them through the predictor formula for that block, then add the residual for that sample.
FLAC does some other things to reduce size. Notably, it can adaptively switch between mid/side channel encoding and L/R channel encoding to try to improve the predictability of a block.
For a very detailed explanation of how FLAC works, please read:
http://flac.sourceforge.net/format.htmlAlso, while FLAC doesn't use huffman coding, I recommend doing a google for it, because it's a very interesting topic if you're interested in how compression works, and rice coding is similar.