Genomic library preparation: Why does the restriction enzyme not cut into the gene?
A genomic library is generated for the purpose of encapsulating the full genetic component of an organism.
You do this by fragmenting the genome with  restriction enzyme that cuts at its recognition sequence. These fragments are then taken and cloned into a plasmid, so that they can then be sequenced inside the plasmid using common sequences that are found on the plasmid but not (generally) in the organism itself. The sequencing would traditionally be performed by Sanger sequencing, which has a limit to how long a sequence you can do at once - really good sequencing will get you ~1000 bp, with sequence quality tailing off after about 600 bp.
The genomic library are not intended for expression - once genes are identified, they can be sub-cloned into an expression plasmid to see what they do. So for this purpose, cutting a gene into fragments isn't a problem, as you will find the rest on another plasmid and can re-construct the full-length gene by taking the two fragments and assembling them.
The reason you use the restriction enzyme is that the sequence that it cuts at is also used for inserting it into the plasmid.
So, at this point you might be asking yourself how do you match the ends of genes (or any sequence for that matter), when they are all cut by an identical sequence?
Well, the answer that is that you use multiple restriction enzymes, either by themselves or in combinations to generate a variety of fragments cut at different sites. This will mean that once you create the libraries from these different digestions, you can sequence through the different libraries and find where the fragments overlap, and then assemble all the sequences together into the original sequence.
For instance if you look at the picture below. If you imagine the the black boxes  are the same gene, and the in the top one is cut with restriction enzyme A and the bottom with B, you can see that the two restriction enzymes generate overlapping fragments, so if you sequence the fragments from both restriction enzymes, you can find where the ends in A match others in A, by looking at the fragments in B.