With all of the Maintenance robots everywhere, in so many of the tunnels, and in stores, and so many in Private homes (not to mention a massive robot factory), most of them art probably survivors of the war that are simply undertaking their duty which seems to be Pest Control and Security.
That is my theory too, and when they see you, since they do not recognize you as authorized personnel, they attack you as an "intruder", that at least explains the ones in metro tunnels and pre-war buildings, I'm not sure where the ones wandering about the middle of nowhere could have come from.