Let's take a simple music sheet:
As you can see, the time signature is given, and it's 4/4. That means every measure has 4 beats of quarters. I assume you know about the duration of the notes.
Every measure/bar in the music sheet is defined by the vertical lines you can see in the image above. Between every two vertical lines, you must have notes whose duration add up to 4 quarters (1 whole, 2 halves, 4 quarters, 1 half and 2 quarters etc).
As per Wikipedia, the measures/bars are used in order to help us read music sheets:
Dividing music into bars provides regular reference points to pinpoint
locations within a piece of music. It also makes written music easier
to follow, since each bar of staff symbols can be read and played as a
In this question you can see how to find the time signature of a song by listening to it.