Since the fence-beam are simple-entity, they are always of the "neutral" force. And since in Krastorio, bullets collide with trees/rocks but not own structures, this means that a turret behind a laser fence will destroy that fence before damaging any enemies.
To fix that, simply change simple-entity to simple-entity-with-force.