You'd be surprised. Remember gif is a very very old format. Even though it's tiny, processing wise it's the equivalent of using pcm for audio... very archaic.
Any paletted image format has to be decoded, which isn't a huge deal, but considering animated gif's can and often do have a separate, unique palette for each frame of animation. Yeah it gets a bit hairy in terms of speed. Not only that, but remember that gif is a closed, licensed format. Because of this, just as an example, directx doesn't support gif. Yes there are ways around that... you can load a gif into directx, but it requires you to load an image vid an external library and convert it to dds. So again speed issues. Remember the gifs you see on the web are maybe 10-15 fps and have maybe 100 frames of animation if it's an especially long one.
All of that being said, yes, with a lot of effort, you can get gifs to work. The thing is, you still have to render them manually... so essentially what you are doing is loading the whole animation into memory, splitting them into individual images, and swapping out the textures one at a time.
So I could do that... Or I could just make a mng via the -writemng option in mame, and then run the command-line advmng utility to split it out into pngs compressing them as they are made. The file size, believe it or not, it comparable to an animated gif of the same framerate and because it's a png it's natively supported by direct x and open gl and loads quite quickly I might add. And yes that's a few steps, but honestly it's still simpler than recording an avi and converting to gif.
h264, btw, is mp4... it's just a compression name while mp4 is the file extension. The problem with those video formats, again, has a lot to do with native support. In terms of playing a video in a picture box with no layering or blending (aka it's on top and nothing can cover it) direct show and similar engines do a fine job with any format windows media player supports. In terms of grabbing frames that can be written to file or put into a texture, direct show only supports basic video formats. By that I mean formats hard-coded into the library. That's avi, mpeg and some versions of mpeg2 (dvd) and that's basically it. Any extended formats, aka videos loaded via a codec can't automatically pull frames. Again with a lot of work it is possible to support mp4 and other codecs, but why bother? For most games it's 240p video at 30 fps.... so why not just use mpeg?