DivX and Xvid are codecs, giving two slightly different, mostly compatible implementations of the MPEG-4 codec.
Strictly speaking, MP4 is the container format for MPEG-4. It's actually very closely related to QuickTime's .mov container.
AVI is nothing more and nothing less than a container format. It can have any of a number of video and/or audio formats, most of which have about as much to do with MPEG-4 as a tomato. A tomato is probably about as good an A/V container as AVI, too.
There's also a DivX container, but I don't think much of anybody uses it, especially since it only really works with the DivX codec.