Gifs are massively space inefficient.
Lemmy converts all images to webps, to save space and bandwidth. It's a very good format for web content.
It can also do animated images, like gifs, but at better quality and smaller file size. Lemmy seems to limit upload file size, not post file size, so sometimes you can get things to work by already converting it to a wepb before uploading, as the file will then start off as small as it can be.
Alternatively, use a media file host like imgur, and grab the url to direct file. Then simply put that in the post url. Other in the thread have mentioned other options.
You can also have stuff in comments. Like this:
To do this you use standard markdown: ![](url to media file)