This phrase refers to the three primary parts of a firearm.
The trigger part of a gun releases the “lock” so you can fire the weapon. The “stock” holds all of the gun’s parts together and provides a grip for the shooter. This is the part of the firearm that was traditionally made of wood. And the “barrel” is the metal tube through which the bullet is fired.
In the past, when you purchased a gun “lock, stock and barrel” it meant that you got the whole gun with no parts missing. It later came into vogue to mean an all-inclusive purchase.