“Gas-operation is a system of operation used to provide energy to operate auto-loading firearms. In gas-operation, a portion of high pressure gas from the cartridge being fired is used to power a mechanism to extract the spent case and chamber a new cartridge.”
So on an AR-15 specifically, there is a small “gas port” (small hole) in the barrel that vents gas with every shot. This gas travels through the gas block and gas tube into the receiver, where it powers the bolt carrier group and auto-cycles the next round. This is known as a “direct impingement” gas system.
The below picture from Wikipedia demonstrates how the gas travels:
Why Does the Length of the Gas System Matter?
The length of the gas system (length from the receiver to the gas port) should increase as the barrel length increases. The reason has to do with “dwell time” – the length of time that the bullet is in the barrel after the shot is fired.
On a longer barrel, the dwell time will be longer, because the bullet has to travel a longer distance. Specifically, there is a tiny amount of time when the bullet is traveling through the barrel and it is past the gas port, but it’s still in the barrel. During this time, there is hot gas traveling through the gas tube into the receiver. As soon as the bullet leaves the muzzle, the gas stops flowing.
If there is too much barrel length after the gas port, then too much gas flows into the receiver and it can causes issues with excessive recoil and wear on the rifle.
If there is not enough barrel length after the gas port, then too little gas flows into the receiver and the rifle may not cycle or may jam.