How memory effects, check dams, and channel geometry control erosion and deposition by debris flows