You sometimes get a bad tube that has been made from porous rubber, or the valve stem might not have been vulcanised in place correctly: it happens.
Maybe the valve O ring was faulty or the valve core had not been tightened correctly.
One of the best methods of puncture protection is keep the tyre pressures correct, and a lot of cyclist including me tend to keep the tyre pressure at the high end of that recommended on the tyre.
Check your tyre pressures on a regular basis .... use the inflator at the filling/gas station, and to help keep you up and running you could add either slime or OKO puncture preventive to your inner tubes ..... these are only to temporarily get you home before fixing the punture properly..... OKO is the better of the two. For re-inflating at the road side, you could carry a CO2 tyre inflator.
http://www.tyreinflators.co.uk/cls-t...FUVTfAodSzBmwA