If you want fairly solid defence for your settlements give some settlers miniguns, you don't need to give them heaps of ammo it's unlimited for them as long as they at least have 1 round.
Companions have unlimited ammo for their original default weapon but any weapon you give them (and force equip) will have ammo limitations the same as you.
I don't recommend you give settlers fatmans![]()