The general rule in both TOS and TNG-era, in broad strokes, was that a matter-antimatter reaction powered the ship and the dilithium crystals channeled the energy from that reaction to the ship's engines in some way. The "lithium crystals" in "Mudd's Women" were part of circuits that burned out when power demands were too high, and then "The Naked Time" established M/AM as the main power source. I used to think "The Alternative Factor" was an exception, since it treated M/AM reactions as something that would destroy the whole universe and appeared to show dilithium as the source of the ship's power, but now I understand that the station Lazarus stole the crystals from was scripted as some sort of charging station, as if the crystals were storage batteries for ship's power, so it's not as inconsistent as I thought (aside from the M/AM thing). The TNG revision is that the dilithium serves as a magnetic bottle of sorts for concentrating the M/AM particles to maximize the efficiency of the reaction (since otherwise they're so small that a lot of them would just miss each other and not react) and then channeling the resultant high-energy plasma to the transfer conduits. That model has been used consistently ever since. But in the movies, it was never clear what role dilithium played. TMP had console graphics reporting on dilithium power levels, but there was no explanation of where the dilithium was in the intermix assembly. Although in Voyager, which was supposed to use the same kind of "swirl chamber" model as TMP (as Rick Sternbach explained it to me once), the dilithium was a vapor-deposited layer on the inside of the intermix cylinder. Of course, TWOK's "reactor room" throws a monkeywrench into all that. It just doesn't fit, either physically or conceptually.