Why are nitrogenous bases of DNA hydrophobic if they can hydrogen bond?
These two concepts are not mutually exclusive. You have constructed a false dichotomy.  Both of these facts are true:


The electrons in the pi orbitals of the conjugated double bonds in the planar rings are hydrophobic and can "stack" on each other as shown in this drawing of a DNA helix where the bases are shown as planar rectangles:





The nitrogen and oxygen molecules (either in the rings, or as substituents on the rings) can participate in hydrogen bonds (H-bonds):




There are other examples of hydrophobicity and H-bonds co-existing.  For example on the interior of proteins.