Disable enemy attacks in Factorio
You can use the console (open via the ` button) and enter this command:
/c game.player.surface.peaceful_mode = true
You will need to enter it twice (as the console text will inform you), and it will disable the achievements from that point onwards for the saved game.
You can use this command to turn peaceful mode on:
/c game.player.surface.peaceful_mode = true
You can open the console by using the ` key.
Peaceful mode will make it so enemies will not attack you unless you attack first. Checkout the Wiki for more commands. Note that this will disable achievements.