Reason behind it that all restriction enzyme are paired with methylases that recognize and methylate restriction DNA sites. After methylation, DNA site(e.g. GAATTC in case of EcoRI) are protected against most restriction endonucleases.
The two enzymes: Restriction endonuclease and methylase are collectively called Restriction-Modification system or R-M System.
But what about newly synthesized strand that will be unmethylated just after replication?? How does it protect it self from its own restriction enzymes??
In this case every time the cellular DNA replicates, one strand of the daughter duplex will be a newly made strand and will be unmethylated. But the other will be a parental strand and therefore be methylated. This half-methylation (hemimethylation) is enough to protect the DNA duplex against cleavage by the great majority of restriction endonucleases, so the methylase has time to find the site and methylate the other strand yielding fully methylated DNA.