Most AVI files nowadays usually has DivX or XviD video in them, so you can install the
DivX codec and the
3ivx codec for those. There are still around some old AVI files that use Indeo Video compression, unfortunately those codecs were never ported to OS X, but you can view them in QT Player Classic. In almost every other case it's a matter of the codec simply being unavailable, e.g. proprietary codecs like Windows Video 9 (which has the fourcc 'wmv3', get info in QT Player when the file is open and you'll see either the decompression component used or the fourcc of the video).
The MPEG files should play in Quicktime if they are proper MPEG-1 files. It's not usual, but there are MPEG-2 video files on the internet, if you want to view those in Quicktime you'll have to buy the
QT MPEG-2 component. In some cases the authors of the MPEG files have simply taken many small MPEG files and stitched them together improperly, making Quicktime misread the timecode. Sometimes people just mislabel files too, putting a .mpg extension on a .avi or .wmv file.
Now that's a lot of work just to view a few video files, which is where
VLC comes in. A good, reliable media player that plays just about everything thrown at it (DivX, XviD, MPEG-1, MPEG-2 and much more), and it isn't bothered by misnamed files or badly made MPEGs. The player recommended to all, basically. Of course, there are good reasons to use Quicktime too, like editing, easy converting etc., but just for playback VLC is one of the best (although there's lots more under the hood, too).