The Ultimate Computer - S2-E24
Corrected entry: When the M-5 computer goes crazy and starts shooting at the other starships, Commodore Wesley INSTANTLY concludes that Capt. Kirk has lost his mind and is trying to kill everyone. Not even for one second does the Commodore think that the M-5, which is going through it's trial test and which has complete control of the ship, is the cause of the problem.
Correction: Kirk was supposed to be able to activate and deactivate the M-5 at will; so the Commodore probably thinks that Kirk still has control of the ship and the M-5, and is giving the order himself to attack the other ships.