As each bullet travels through the AK barrel, a portion of the gases expanding behind it is diverted into the gas tube above the barrel, where it impacts the gas piston. The piston, in turn, is driven backward, pushing the bolt carrier, which causes the bolt to move backwards, ejecting the spent round, and chambering a new round when the recoil spring pushes it backfire, automatically cycling fresh rounds into the chamber, until the magazine is exhausted or pressure is released from the trigger.
All gas operated rifles like the AK and AR have a gas port in the barrel that directs gasses back to cycle the action, either by way of a piston (AK) or the direct impingement method (AR15).
"There is no hunting like the hunting of man, and those who have hunted armed men long enough and liked it, never care for anything else thereafter." - Hemingway
“The greatest ignorance is to reject something you know nothing about.”