It wasn't so much that Lassard was technically unable to throw him out, he just had promised that to Captain Reed, who chose the Police Academy as an alternative to jail for teaching Mahoney some discipline. So it was more a personal than a technical decision to not throw him out for the many pranks he tried, since those were probably not strict (even if possible) reasons for getting expelled.
But once Mahoney started (or claimed to have started) a fight with another recruit, he had crossed a line where even Lassard as commandant wasn't able to keep him at the Academy anymore and Harris finally got a legitimate reason to expel Mahoney. Fighting was just too heavy a misdeed to be ignored on the commandant's preference and was probably strictly written as a reason for expellance, which is also stated by Copeland (or Mahoney himself?) just before the fight, I think (and was in fact also the reason why Hightower was thrown out).
At least that's how I understood the story, or how one could make some sense out of this. (Still one could ask the question why Mahoney didn't try this earlier, when he still wanted to get thrown out, but I'd really attribute this to some logic sacrificed for the sake of the story, as like you said, "the script was just not thought through in that detail".)