tl;dr: Because all notes A have the same frequency, in some sense of frequency.
The thing that makes you hear a note are sound waves. The guitar string vibrates the guitar body which vibrates the air molecules all around us. The vibration in the air is in the form of a "traffic jam" of air molecules: Some molecules start moving fast (because they were bumped by the moving guitar string), these bump into molecules moving slow; fast molecules (from the guitar string) are again coming in hot from behind, and so on as long as the string vibrates.
Vibrating air molecules:
The vibrating air molecules bump into your ear drum, which vibrates some tiny bones in your ear, which excite some brain neurons.
Anyhoo, sound is all about vibrations. The simplest forms of vibrations are periodic. "Periodic" means that the vibration doesn't "change" in some sense, in the way your metronome goes back and forth and back over and over in the same monotonous fashion. When you pluck your guitar string, the vibrations aren't perfectly periodic (the note fades off as you let it ring), but it's pretty close. It turns out that when you pluck a particular guitar string, and it starts moving back and forth and back - then just like your metronome, the rate at which it goes from one side to the other and back of its vibration does not change, even if it gets softer over time. This is kind of magical, and you should take a moment to let that sink in.
This factoid is what makes a particular string on a guitar ring at a certain "note". The "note" is the "period" of the vibration of the string. The time it takes for the string to go from one side to the other. In the case of A4 on a piano, the time it takes the string inside the piano to go from one side to the other and back in its vibration is 1/440th of a second. This is what we mean when we say that "A4 is 440Hz".
The next A note above A4 is A5 at 880Hz. This means it takes 1/880th of a second to go from one side to the other.
Here's the kicker: If A5 takes 1/880th of a second to go from one side to the other, then it takes 1/440th of a second (i.e. twice 1/880th of a second) to go from one side to the other and back and to the other and back. So, if we pluck A4 and A5 at the exact same time, then after 1/440th of a second, the strings are both back at the same position. After another 1/440th of a second, they are back at the same position again. In some sense, the frequency of A5 is 880Hz, but it is also vibrating at 440Hz. The converse is not true: the frequency of A4 is not 880Hz, because after 1/880th of a second from being plucked, the A4 string will not be back where it started. The "frequency" that we assign to a named note is related to the shortest time it takes for the vibration to get back to its original position. So, if it takes you 50s to run a lap around the track, you can run two laps in 100s and three laps in 150s. In fact, any multiple of 50s will see you right back at the start (==finish) line. A5 can run a lap exactly twice as fast as A4, so every time A4 makes a lap, she sees A5 at the start line. A5 only sees A4 every other time.
Here is a simplified illustration. In the following picture, the x-axis is time, and the y-axis is the extent of your guitar string up vs down after you pluck it (or the pressure of the air, high vs low at some point near your ear, or the extent of your eardrum, in vs out).
The 0.01 on the x-axis is in seconds. That's right, remember that our string is going back and forth at 440Hz - that's 440 times per second! For reference, low-E on your guitar is E2 at about 82Hz. Pluck your low E string and see if you can count the number of times the string goes back and forth in one second. :)
A5 is higher pitched, meaning that the string is vibrating faster: 880 times per second.
If we plot them together, we see that every other time our A5 string is at the top of its vibration, our A4 string is also at the top of its vibration! In other words, both A4 and A5 vibrate at 440Hz (but A5 also vibrates at 880Hz, and A4 does not). There's nothing particularly special about the top: if we plucked them at slightly different times, then perhaps our A4 string would be at the top every other time A5 is at the middle (different "phase"). It's happening so fast that we don't "hear" the phase, but we do hear the alignment. The important aspect here is the lining up "every other time". That is what musicians mean by calling both of these notes "A". The fact that its "every other time" and not "every time" is the difference between A4 and A5.
A4 and A5: