Hi ro
It's all about the CODECs. (bear with me here)
Both MP4 and AVI are merely containers for compressed video files. You can compress video in a wide range of methods, some of which occupy more or less space on a disk than others.
Compression is there to speed up data transfer, reduce the space on the disk and generally make the video files easier to manage.
More compression generally means smaller disk files, but the video quality will suffer in one way or another (resolution / frame rate / more noise / whatever)
The amount of compression is defined by the CODEC (stands for enCoder-Decoder).
When you convert a raw video file to AVI or MP4, the software uses a specific CODEC to do that. The resulting file size depends on the codec that is used.
Typical CODECS include:
H.265/MPEG-H HEVC codecs
H.264/MPEG-4 AVC codecs
H.263/MPEG-4 Part 2 codecs
H.262/MPEG-2 codecs
Microsoft codecs.
So the CODEC used in your MP4 compression software is probably different from the CODEC used in the AVI compression.
Somewhere in the software settings you may well find a way to select the specific CODEC used.
There's more information here:
https://en.wikipedia.org/wiki/Video_codec
Good luck