When D-Squad, led by ColonelMeebur Gascon, infiltrated a Separatist ship, M5-BZ's memory banks were removed by the Parwan doctor Gubacher so that Gascon could fit inside the droid and use it as his command center.
Gascon inside BZ's head.
While trying to open a door, M5-BZ backfired and the droid short-circuited. Gascon was forced to ride on top of U9-C4 for most of the rest of the mission.
Although Gascon did not at first approve, R2-D2 and WAC-47 brought the short-circuited droid back with them for repairs.
Later he was ejected into hyperspace after he opened an airlock on board a Venator-class Star Destroyer called the Renown in order to destroy all of the Buzz Droids who where attacking D-Squad. D-Squad would remember him as a hero for sacrificing himself to save the others.