Bistable electrical conductivity switching behavior and write-once, read-many-times (WORM) memory effects have been demonstrated in Al/polymer/ITO sandwich devices. These devices were constructed from two poly(N-vinylcarbazole) derivatives with pendant donor–trap–acceptor (D-T-A) structures. The observed electrical bistability can be attributed to the field-induced charge-transfer interaction between the carbazole electron-donor unit and the terminal electron-acceptor unit, and subsequent charge trapping at the intermediate azobenzene chromophores. The charge-transfer and trapping processes are further stabilized by the conformational relaxation of the total energy of the D-T-A system through donor–acceptor electrostatic interaction. The proposed switching and conduction mechanism is supported by density functional theory calculations, UV/Visible absorption spectra, core-level X-ray photoelectron spectra, and high-resolution transmission electron microscopy images of the polymer thin films. The influence of the charge-trapping effect of the azobenzene mediator is further explored by studying the electronic properties of two other poly(N-vinylcarbazole) derivatives as the control samples, in which nitro or cyano acceptor groups are directly bonded to the carbazole electron-donor moieties.