Push a shopping cart and note that the castered wheels have a tendency to shimmy. The castered wheel on a shopping cart has a vertical steer tube axis and negative rake, which results in positive trail and negative fork flop. The negative fork flop, a result of the combined wheel and fork center of gravity being behind the steer tube axis, is a partial cause of the shimmy. Most bikes avoid this by combining positive rake with a headtube angle that results in both positive trail and positive fork flop. Another factor related to dynamic stability is the stiffness of the bike frame.
All bikes flex somewhat, but in general the idea is to make the frame as stiff as practical.
This does not prevent the oscillation exactly, but makes the natural frame oscillation frequency higher. If it no longer syncs up with the fork shimmy oscillation frequency then the feedback loop is broken and oscillation is reduced or eliminated. The fork oscillation frequencyis related to the rotational inertia of the wheel, fork, handlebars, etc. This poses a possible problem for recumbents as typically smaller lighter front wheels coupled with longer more flexible frames can provide just the right combination for oscillation. Bikes with fairings provide another opportunity for oscillation as the weight of the fairing suspended from the frame by what are often somewhat flexible mounts present an energy storage media.