For most of season 3, Derpy had fallen victim to some sort of space-time anomaly that caused her and all memories of her to be erased from existence.
Derpy’s daughter, Dinky, didn’t get disappear, though. To prevent the universe from collapsing in on itself as a result of this, memories were rewritten by the anomaly in such a way as to make Derpy’s best friend Carrot Top, previously an aunt figure for Dinky, into Dinky’s mother.
Doctor Hooves played a part in undoing the anomaly and getting Derpy back. Carrot Top probably helped too, but if I elaborate any further, this post will be upgraded from headcanon-level to fanfic-premise-level. >_>