  Diffuse striations in molecular clouds are preferentially aligned with local
magnetic fields whereas dense filaments tend to be perpendicular to them. When
and why this transition occurs remain uncertain. To explore the physics behind
this transition, we compute the histogram of relative orientation (HRO) between
the density gradient and the magnetic field in 3D MHD simulations of prestellar
core formation in shock-compressed regions within GMCs. We find that, in the
magnetically-dominated (sub-Alfv\'enic) post-shock region, the gas structure is
preferentially aligned with the local magnetic field. For overdense sub-regions
with super-Alfv\'enic gas, their elongation becomes preferentially
perpendicular to the local magnetic field instead. The transition occurs when
self-gravitating gas gains enough kinetic energy from the gravitational
acceleration to overcome the magnetic support against the cross-field
contraction, which results in a power-law increase of the field strength with
density. Similar results can be drawn from HROs in projected 2D maps with
integrated column densities and synthetic polarized dust emission. We
quantitatively analyze our simulated polarization properties, and interpret the
reduced polarization fraction at high column densities as the result of
increased distortion of magnetic field directions in trans- or super-Alfv\'enic
gas. Furthermore, we introduce measures of the inclination and tangledness of
the magnetic field along the line of sight as the controlling factors of the
polarization fraction. Observations of the polarization fraction and angle
dispersion can therefore be utilized in studying local magnetic field
morphology in star-forming regions.
