Formation of flint & chert in limestones/chalk
This is not really my specialism, but in the absence of other answers so far, I'll give it a go.

Firstly, to simplify the terms of the question a little bit, flint is a form of chert, so we don't need to distinguish the two terms: we can just talk about chert in general. Also, I'll ignore chert beds formed in siliceous oozes, since you're specifically asking how cherts form in carbonate beds. Nichols (2009) gives a concise explanation, and I don't think I can do better than to quote it:


  Diagenetic cherts are formed by the replacement of other material such as calcium carbonate by waters rich in silica flowing through the rock. The source of the silica is mainly biogenic with the opaline silica of
  diatoms, radiolarian and siliceous sponges being redistributed. Chert formed in this way occurs as nodules within a rock, such as the dark flint nodules that are common within the Cretaceous Chalk, and as nodules and irregular layers within other limestones and mudstones.


If you want more detail, Maliva and Siever (1989) would probably be a good reference. (Free online reading for all, and download for many institutions, at the JSTOR page.) Here's the abstract:


  Mapping of carbonate dissolution in nodular chert-bearing strata indicates that nodular chert formation in a diverse suite of Phanerozoic limestones occurred in bulk pore waters that were at calcite saturation. Opal-CT and quartz supersaturation was achieved in most chert-bearing strata by the intraformational dissolution of amorphous silica skeletal material. Chertification occurred by a combination of force of crystallization-controlled replacement of the host carbonate, whereby non-hydrostatic stresses resulting from opal-CT and quartz crystal growth caused calcite dissolution, and the isomineralic heterogenous nucleation of new opal-CT and quartz crystal at nodule peripheries. The restriction of the solution phase at silica-carbonate contacts to thin films permitted the preservation of ghosts of micron-sized features in the chert. Heterogeneities in sediment organic matter content, porosity, and biogenic silica concentrations promote the nucleation of chert nodules in some formations.





Maliva, R. G., &amp; Siever, R. (1989). Nodular chert formation in carbonate rocks. The Journal of Geology, 421‒433.
Nichols, G. (2009). Sedimentology and stratigraphy. John Wiley &amp; Sons.