A Unified Accreting Magnetar Model for Long-duration Gamma-Ray Bursts and Some Stripped-envelope Supernovae