they get the number from the direction/angle in which the runway is facing when placed onto a 360 degree compass.
for example, the runways at heathrow are 09 and 27.
runway 09 is at an angle of 90 degrees from 0 degrees on a compass and the other end of the same runway is 270 degrees (always 180 degrees above the smaller numbered end of the same runway) from 0 degrees, hence the runways being named 09/27.
now, at heathrow, there are two runways which face the same direction/angle and have left (L) and right (R) after their numbers.
so, runway 09L begins at the terminal 5 end of the airfield facing towards central london on the north side of the airport; i.e. if you were standing inbetween the two runways facing towards london this one would be on your left. the opposite end of the same runway is 27R (facing windsor) - the left and right of each parallel pair of runways always swaps around when you face the other direction.
the other runway is 09R/27L - on the south side of the airfield, closest to terminal 4.