Pathway conversion enables a double-lock mechanism to maintain DNA methylation and genome stability