FIFO means first in first out and an example will be more illustrative.
Lets say that you buy 1,000 units of a material for $1 each.
Then you buy another 2,000 units of the same material for $2 each.
Then you sell 800 units of this material. The value of the inventory is the 200 units that is left from the first batch plus the full second batch so 1*200 + 2,000*2 or $4,200 while the cost of sales is 800*1 or 800!
Therefore, in order to get the cost of sales, you take units from the older purchases and the you move to the purchases that were made later and so on.