Autofill is a feature that can be toggled on by clicking the hand icon near the bottom-left corner of a bag's menu. When toggled on, it will make items that you pick up automatically get placed inside of the bag.
In this example, the 3 stone I pick up are automatically transferred to my mining bag. (Stone quantity inside bag goes from 45->48)
Note: You can also toggle autofill on specific items. If autofill is turned on for your bag, then hover over an item slot and click the small hand icon in the top-left corner of the slot to toggle autofill of that specific item. This can be especially useful if you have multiple bags that can store the same item, but you want that item to be autofilled into a particular bag.
Autofill only happens when you pick up items that you don't already have an existing stack of in your inventory. EX: You have 998 wood in your inventory. You pick up 1 wood. It doesn't autofill, stacks with the 998. Then you pick up another wood. Rather than making a new stack with qty=1 in your inventory, that wood can be autofilled into a bag that you're holding. Autofill isn't only for items added to your inventory. It can also happen when you deposit items into a chest, if the chest already is holding a bag that has autofill toggled on.