Compression is done according to standards, a simple concept might be to say the line above the current line is the same as the current one however the next line is a new line (it would be practically unwatchable but you get the idea). A codec is simply something that can either encode a or decode a (or both) compressed stream that follows a standard that it is designed for (codec is an amalgamation of enCOder DECoder).
Naturally you need to be able to decode the video to encode into a new standard (a process known as transcoding) so this is where codecs come in. Many codec packs install codecs without regard for the standard they decode (xvid, divx, 3vix and msmpeg4 all decode the same standard more or less) and can cause major issues as they all fight over it (not to mention some are slower than others). Related to this is a splitter which is there to get the video stream, audio stream and whatever else you might have in a container (AVI, WMV, MKV, quicktime, RMVB (real), MP4 etc) and feed it into the decoder.
Various people have attempted to combine codecs with the one of the most well known (and certainly one of the best) being FFDshow (others include mplayer/mencoder). The original author has vanished but various people have taken to keeping it updated and fixing it, the links I gave being the most popular of these alternative versions.