Even since the earliest of times, man learned that you could change the pitch of a brass instrument, such as the trumpet, by changing the length of its tubing. The shorter the tubing is, the higher the pitch of the note played is. A trombone works just like that- the slide on it moves, changing the instrument's overall length. For many years, the trumpet had no valves, and was only able to play the harmonic series, which limited the number of notes it could play to about seven, much like a bugle. In the 1800's, the valve system came into existence, and revolutionized the way trumpets would be played thereafter.
Valves work by redirecting air into "loops" of extra tubing. When no valves are pressed down, the air travels directly from the mouthpiece, down the leadpipe, through the valve assembly, and then into the bell. There are no unnecessary additions to the tubing. When the first valve is pressed down, though, it takes the air coming in from the mouthpiece and leadpipe and redirects it to the first valve's extra tubing and then back into the bell of the trumpet. In effect, all the valve does is temporarily lengthen the trumpet.
As a result of this, a note played without any valves down is the highest note in it's series, and is called a fundamental. The shortest valve is the second valve, and when it is pressed down, the fundamental is lowered one half step. The next longest is the first valve, the one closest to your face, and it lowers the fundamental a whole step. The last valve is the third which lowers the fundamental one and a half steps. The third valve is usually not used by itself, because pressing down both the first (one step) and the second (half step) valves lowers the fundamental the same amount (one and a half) as the third by itself, but is usually more in tune. The third is most commonly used with other valves to produce lower notes.