Compare it to a trombone. the length of the horn controls the pitch. The trombone just slides the length of the trombone to make it longer and shorter. The trumpet uses valves to make the air go through tubes of varying length. Combining the valve buttons makes for a range of lengths that is quite analogous of three bit binary.
There are, of course more details to trumpets, But this gets the basic idea of a number of on-off states generating a range of values.