I think on another topic about this some other clever dude I think had cracked it, I'm here to confirm he was right.
The Defences work as a deterrent to bands of Maurading bandits or super mutants. If your base has a higher defence than food or water count, you will not be attacked. This, as I was to discover is true!
I've recently set up a new settlement at that Co-op settlement place - not thinking I started planting crap loads of food without building defences or many walls for that matter.... Within the 24hr period, maybe longer I don't know (as I fast travelled back to my Red Rocket settlement to grab some guns and clothing to give to my noob settlers)........
Well, before much longer a pack of super mutants attacks my camp. I wasn't ready..... They killed me first! It was great! I had NEVER seen anything or anyone attack my base before.
Just thought I'd share if any other folk have put way more hours into there settlements than me and have been thinking it was perhaps a bug....
Some things in this game are not really explained......