Keep all the ammo on yourself.
Settlers are almost always universally armed with .38 caliber weapons and those will be the weapons they'll swipe then. They're not going to steal a laser rifle if there is no fusion cells around to load into it.
I've had items stolen from my workbench by settlers. I had a fat man and a missile launcher in there, with ammo, and when attacked, my nearby traders would apparently grab them. (And by that, I mean have them magically appear in their inventory.)
Considering your standard settlers can apparently only die if you kill them yourself or if they get caught in an explosion while "knocked out," you can see how this is a very bad thing.
I started storing the weapons and ammo in separate settlement workbenches, and this issue has stopped. This would be my recommendation, though you'll need to do more running around if you want to use those weapons.
To my knowledge, I have never had a settler take anything out of any containers that I built. They never have anything in their own inventory except the same few items they have always had. All of my containers have been "safe" thus far.
This has been true for me but only for settlements which have never been attacked. (Either via actual "Defend Settlement" missions or just by random spawns nearby.)
In my first play through, I used Sanctuary as my main base. Never attacked, never had an issue with stored weapons.
This time, I decided to use the Drive In as my main base (as well as my hub for traders and provisioners.) Because there is a "travel anomaly" under the bridge right outside the gates, my provisioners passing through there get attacked frequently, which sets my turrets off and has all of my settlers running to defense.
It is during those times where the weapons I have stored will magically appear in their inventories. (So far, it has only been with heavy weapons. I've seen it happen with a fat man, missile launcher, and railway rifle I've had in storage there.)
But they only seem to do it if there is also ammo available. Started storing my ammo in a footlocker at Sanctuary, and this hasn't happened since despite several attacks.
Simple solution dont store ammo with it and you will be fine, also i wudnt rly call it stealing i mean they live there get attacked and sure if they see a shinny moded plazma rifle with ammo they will naturaly use that instead of their scrap 0,38 pipe pistol i mean wudnt you:)
Build a room for yourself with only access being a way that you can get in. build storage boxes in that room. then its all safe.
all you need is a gap that the NPC's cannot walk across, a set of stairs that has a gap you have to jump across is good enough. but if your really hardcoe you could build a tree house or on top of a platform with the only access being the Fast Travel pad.
I've heard people suggest this, but I'm really skeptical that it works. The Settlers I had who kept taking my weapons weren't physically running over to my workbench to take them. The attack would happen, and the stored weapons would just sort of magically appear in their inventories.
Even if I put them up on a platform only I could get to by jumping for instance, I don't think it will stop their magic item grab.
This hasn't worked out for me. I built a huge 6 story fortress on top of the over pass at Finch Farm. I am the only one that can get up there by way of the fast travel pad. I initially built steps to get up, then removed them. Now fast travel is the only way to get up there. I made each floor without walls, by the way. The 360 view is truly spectacular! I put railing all the way around each floor.
For the longest time, I never saw any settlers up there. Then one day, I fast traveled there, and they were ALL up there milling about on my private penthouse floor. Doesn't happen often, but has happened a couple of times.
Perhaps this has been my case. I have never stored ammo. I only keep the ammo that I use for the weapons I carry, the rest I sell to my vendors. So, I do not have ammo that I wish to store.
Thats pretty bizarre, I've built myself a little room on the 3rd floor of my Sanctuary house with an air-gapped stairway and I've never seen any of them get in there. I've even frustrated my companions once or twice by running in there and they are stuck at the stairs.
when you consider that I have a box with thousands of ammo, and another box with almost every legendary drop I've gotten in it, and none of them have tried for it, maybe its just cause i keep weapons, ammo, outfits in their own boxes?
Storing your weapons and ammo in separate boxes at the same settlement may work. I'll have to try that so I don't need to make the second trip every time I want my fat man.