“S”, “M”, “L”, etc. don’t really mean very much. Actual sizing varies between manufacturers and bikes have gotten longer, but with shorter seat tubes in the last few years. A modern “S” is likely to be as long as an older “M”. Different people have different body proportions, so two people of the same height might need different sized bikes.
Ideally, you’d compare reach (the horizontal distance from the bottom bracket to the top of the head tube), but that is tricky to measure. An easier thing to measure is effective top tube, which is horizontal distance from center of steerer to center of seatpost. Only problem with that is that newer bikes tend to have steeper seattubes, so you might find that you set your saddle further forward on older bikes, which has the effect of shortening the effective top tube.
Seattube length doesn’t matter within reason except that you need to check that you can fit a dropper post in with enough drop for what you want to do.