  Motivated by recent experimental observations of opposite Chern numbers in
$R$-type twisted MoTe$_2$ and WSe$_2$ homobilayers, we perform large-scale
density-functional-theory (DFT) calculations with machine learning force fields
to investigate moir\'e band topology from large to small twist angles in both
materials. We find that the Chern numbers of the moir\'e frontier bands change
sign as a function of twist angle, and this change is driven by the competition
between moir\'{e} ferroelectricity and piezoelectricity. Our large-scale
calculations, enabled by machine learning methods, reveal crucial insights into
interactions across different scales in twisted bilayer systems. The interplay
between atomic-level relaxation effects and moir\'e-scale electrostatic
potential variation opens new avenues for the design of intertwined topological
and correlated states, including the possibility of mimicking higher
Landau-level physics in the absence of a magnetic field.
