In order to customize weapons, you need to build the gunsmith bench. If you started the game recently, then this bench is already installed in your base. Then you’ll have to find a blueprint, learn it and then craft the modification. To create the modification from resources, place the character next to the right part of the workbench.

Every weapon has a slot for modified parts. Having chosen a slot, you can place one of modifications in there. Depending on the weapon, the number of slots may differ.