A tempo can establish mathematically precise intervals for the duration in between pitches. A tempo can establish that a quarter note will last two seconds, a half note will endure 4 seconds, an eigth note 1 second, and so on. We establish a tempo which tells us how many beats per minute (BPM) and then we can organize and separate the rhythmic durations with the help of vertical 'bar lines.' Each of these groupings constitutes a 'measure' or 'bar.' While most measures are of the same length in Western music, this is not a hard and fast rule, and there are plenty of exceptions. For example, each bar may be 4 seconds, with more or less pitches, depending upon the duration of each pitch. But it is not necessary to make each bar of the same duration.
We organize the durations and the beats with the help of the so-called time signature. The time signature is two numbers, one on top of the other, at the beginning of the piece of music. The number on top indicates the number of beats per measure or bar, and the bottom number indicates which duration will represent the beat (Blatter, p. 16). For example, a 2/4 time signature means that there are 2 of the specified notes per bar, and the 4 indicates that these notes will be quarter notes.
Keep in mind that all this means is that we must have the mathematical equivalent of two quarter notes per bar. It does not mean that we must have exactly two quarter notes per bar. This means that it is possible for one bar to have two actual quarter notes whereas another bar may have two eighth notes and one quarter note, which adds up to two quarter notes. Likewise, one of the measures might have only one half note, which would equal 2 quarter notes. Or suppose we have a 2/2 time signature. This could be divided up into two half notes (the lower top indicates that the half note represents the beat) or it could be represented by a half note and four eighth notes, or however one divides to divide up the pitch duration per measure.
Blatter, Alfred (2007). Revisiting Musical Theory. Routledge, Taylor and Francis Group, NY.