In the flow past elongated rectangular cylinders at moderate Reynolds numbers, vortices shedding from the leading- and trailing-edge corners are frequency locked by the impinging leading-edge vortex instability. The present work investigates how the chord-based Strouhal number varies with the aspect ratio of the cylinder at a Reynolds number (based on the cylinder thickness and the free-stream velocity) of
$Re=400$
, i.e. when locking is strong. Several two-dimensional, nonlinear simulations are run for rectangular and D-shaped cylinders, with the aspect ratio ranging from
$1$
to
$11$
, and a global linear stability analysis of the flow is performed. The shedding frequency observed in the nonlinear simulations is predicted fairly well by the eigenfrequency of the leading eigenmode. The inspection of the structural sensitivity confirms the central role of the trailing-edge vortex shedding in the frequency locking, as already assumed by other authors. Surprisingly, however, the stepwise increase of the Strouhal number with the aspect ratio reported by several previous works is not fully reproduced. Indeed, with increasing aspect ratio, two distinct flow behaviours are observed, associated with two flow configurations where the interaction between the leading- and trailing-edge vortices is different. These two configurations are fully characterised, and the mechanism of selection of the flow configuration is discussed. Lastly, for aspect ratios close to the jump between two consecutive shedding modes, the Strouhal number is found to present hysteresis, implying the existence of multiple stable configurations. Continuing the lower shedding-mode branch by increasing the aspect ratio, we found that the periodic configuration loses stability via a Neimark–Sacker bifurcation leading to different Arnold tongues. This hysteresis can explain, at least partially, the significant scatter of existing experimental and numerical data.