DNA methylation provides an important epigenetic mechanism that critically regulates gene expression, genome imprinting, and retrotransposon silencing. In plants, DNA methylation is prevalent not only in a CG dinucleotide context but also in non-CG contexts, namely CHG and CHH (H = C, T, or A) methylation. It has been established that plant non-CG DNA methylation is highly context dependent, with the +1- and +2-flanking sequences enriched with A/T nucleotides. How DNA sequence, conformation, and dynamics influence non-CG methylation remains elusive. Here, we report structural and biochemical characterizations of the intrinsic substrate preference of DOMAINS REARRANGED METHYLTRANSFERASE 2 (DRM2), a plant DNA methyltransferase responsible for establishing all cytosine methylation and maintaining CHH methylation. Among nine CHH motifs, the DRM2 methyltransferase (MTase) domain shows marked substrate preference toward CWW (W = A or T) motifs, correlating well with their relative abundance in planta. Furthermore, we report the crystal structure of DRM2 MTase in complex with a DNA duplex containing a flexible TpA base step at the +1/+2-flanking sites of the target nucleotide. Comparative structural analysis of the DRM2-DNA complexes provides a mechanism by which flanking nucleotide composition impacts DRM2-mediated DNA methylation. Furthermore, the flexibility of the TpA step gives rise to two alternative DNA conformations, resulting in different interactions with DRM2 and consequently temperature-dependent shift of the substrate preference of DRM2. Together, this study provides insights into how the interplay between the conformational dynamics of DNA and temperature as an environmental factor contributes to the context-dependent CHH methylation by DRM2.