Porygon2 is a failure because it was designed for space exploration, but it can't fly and sometimes it may exhibit motions that were not programmed. But it was not a complete failure, because it was given artificial intelligence that enables it to learn new gestures and emotions on its own.
As for Porygon-Z, Game Freak is very vague. They said " It began acting oddly, however.", "It did not work as planned.", and " Seems there might have been an error...". There is really no way to tell what the error was, although it could be becoming too intelligent.
Hope I helped! :)