How do plasmids protect themselves against restriction enzymes?
The strains that we use in the lab have defective restriction machinery.

In the case of DH5α it is mostly because of the endA1 and hsdR17 mutation. The former mutation eliminates an endonuclease that can degrade plasmids and the latter one eliminates the restriction system.

Check this.