What is a beat?
A beat is the stimuli you feel that gives music a time compass. Oftentimes, it is referred to as "the thing that makes you tap your foot".
What is a pulse?
A pulse is, essentially, a beat. However, for a pulse to be a pulse, it needs to be a series of beats that are perceived to be in time with each other, spaced apart in a similarly constructed amount of time.
What is a rhythm?
The word "rhythm" actually has a few different meanings depending on the context, but in the context of written music (and music in a DAW Piano Roll), it is the combination of sound and silence and the placement in time in which they occur.
What is a time signature?
A time signature is a convention for notating musical time, as a representation of how many beats in a unit of measurement known as a measure, over the note value that is the representation of a single beat. This means:
1 = 1 beat in a measure
4 = a quarter note is one beat
2 = 2 beats in a measure
4 = a quarter note is one beat
3 = 3 beats in a measure
4 = a quarter note is one beat
4 = 4 beats in a measure
4 = a quarter note is one beat
It is also possible to have combinations such as:
4 = 4 beats in a measure
2 = a half note is one beat
...or any such combination if you so desire it. The premise does not change:
X = X beats in a measure
X = a subdivision of 1/X is one beat
Putting it together
A time signature is measuring the length of a measure and how it's being calculated, not the length of a note nor the speed of the pulse. So, your example #1 is a measure of 4/4 (I know this because there are 4 major subdivisions between measure 1 and 2). There are 4 notes, all of which are exactly one quarter note in length. Therefore, this is one measure with 4 beats, and they are neatly outlined in the rhythm: 1/4-1/4-1/4-1/4. The total value is 4/4, so this is a complete measure.
Your example #2 is a measure of 4/4 (I know this because the 4 major subdivisions between measure 1 and 2 are still there). There are 4 notes, but not all of them are one quarter note in length. As a matter of fact, none of them are. This does not mean the measure is not a 4/4 measure. It means that both examples are examples of different rhythms.
How is this a different rhythm if the sound has the same pulse?
Measures have to be validated by the amount of sound and silence combined. That means that the values given should add up to the number given in the time signature. This includes note values for sound and rest values for silence.
As I explained above, example #1 has a simple rhythm of 1/4-1/4-1/4-1/4. You add these up and you get 4/4. Simple.
Example #2 is deliberately chaotic, so this will take some explanation.
The first note seems to have a value of approximately 7/32. There is no "7/32" note in written notation, so normally we "tie" note values together to equate the odd value. We'd require something like an eighth note(or, 4/32)+a sixteenth note(or, 2/32)+a thirty-second note(1/32), all tied together. There is a silence that is 1/32 in value before the next sound.
The second note seems to have a value of approximately 5/32. Again, there is no "5/32" note in written notation, so it'd be written out as possibly an eighth note + a thirty-second note, tied together. There is a silence of 3/32 in value. There is no 3/32 note or rest, so it'd be one thirty-second rest, and a sixteenth rest. You don't tie rests, they're just silence.
The third note is squarely one eighth note in value. The following rest is also one eighth in value.
The fourth note is approximately three sixteenths in value. Normally you'd try to use the largest possible value to fit in, so it'd be one eighth and one sixteenth, tied together. The remaining silence is one sixteenth, so now there's a one sixteenth rest.
Despite the fact that the two rhythms are, in fact, very different, the fact that all of the sounds align with the pulse makes them sound very similar. Or, rather, it's because in both examples the sounds all start at the same times that you can feel the pulse the same way.