How are weapons affected by SPECIAL?
The mentioned stat for each weapon is the stat that is used for building the weapon. It affects the time to construct the weapon in a workshop.
The workshop initially has no main stat (as a power plant has S, labs have I, etc), but when you allocate dwellers here and select some weapon to build, it will get the stat associated with the weapon as its primary stat. The specific stat can be different, depending on which weapon you chose.
So say you want to build a weapon with S - then, if you assign dwellers with high S, it will go faster. Also, you can equip outfits on them, so the best stat value for a dweller can be 10 + 7, which can make crafting even legendaries really fast if you have all the dwellers properly equipped. You can go down to something like 2m30s for rare weapons, and like 10-12 hours (if I remember correctly) for some legendaries.
Those stats have no use other than computing the crafting time.
Crafting outfits works the same.
As I've discovered, this has nothing to do with a weapon's, or Dweller's attributes. What this is referring to is the stat required to make the weapon.
Eg., Pistols generally require Agility, Rifles generally require Perception, there are a few weapons listed as "Institute" weapons that are the only ones that require intellingence to build, and the rest require Strength to build.
This has nothing to do with the weapon's performance.