The Latin word tandem means “at length (with respect to time),” that is, “for a long time.”
Back in the eighteenth century, when the study of Latin was a normal part of English university curricula, some student noticed a carriage harnessed to two horses, one before the other, and, being somewhat of a wag, he coined a pun on the word by applying it, in the sense of “at length (with respect to distance),” to a team so harnessed.
The pun caught popular fancy, so that it has lived long after most people realize that it is a pun, and the sense has become broadened to include any of many things or events which may be arranged in consecutive order, one after another.