How did a "B-side" songs make the charts?

Ever hear the Beatles’ “the Inner Light” on the radio? Neither did anyone else, really. It hit #96 for one week, but the other side, “Lady Madonna”, hit #1 for two weeks.