The lightning strike didn't make EDI go berserk and start hunting targets solo
In fact, it may have been what finally let him stop. EDI is described as a machine that learns from pilots. On its first mission, EDI sees Gannon disobey orders to get the mission done. Though it is struck by lightning in the interim, disobey orders to go after targets is precisely what EDI does the following day. EDI's designer flat-out told them that EDI could learn from anything. The additional code that EDI spends time writing following the jolt however, later indicated to be something like emotion, is what finally seems to bring EDI out of what it is doing some time later, remarking that it killed many people and feels sorry.