An airsoft mosfet acts as a solid state relay. If you understand how a relay works then you know how a fet works.
The wires in essence go directly from the battery to the motor. And the fet breaks one of those wires. When a signal voltage is applied to the fet it allows the fet to open, this makes the gun shoot.
The advantage of the fet is the signal wire uses very low current to operate. This means because it's low current the mechanical contact points of the guns switch (trigger) do not spark (arc). The lack of this arcing means the contacts don't burn out.
You also have the advantage of the main gate part of the fet having a low resistance compared to the mechanical switch (trigger). This means more current to the motor, and 0 losses through the switch (trigger) as it is only providing a signal and not dealing with the total current drawn by the motor. Reduced resistance for the whole circuit mean better ROF and trigger response.
For an M4 build you are totally dependant on the available space in the stock. You will have no space over or at the side of the gearbox. With that in mind the best solutions for an m4 in my opinion would be a self soldered pico fet. It would require knowledge of how to solder, use heatshrink, and follow a wiring diagram.
The "gate PicoSSR 3 " is a good place to start with the searching about actual fet models. It's small enough to be wired into the buffer tube on an M4, but in order to do so you have to strip the gun and gearbox, make a new wiring loom, and solder it all in place. This means it's one of those jobs that is it best to pay someone to do for you if you have any apprehension at all.