1. Question: Why does pesach or sukkos cancel the rest of Shiva and shloshim for a mourner even if he first hears about the burial on Shabbos and yom tov starts the next day?
A. The Shulchan Aruch (Yoreh Deah 399:1) says that one who buries the dead before yom tov and is able to go through the process of mourning at least one hour before the yom tov has the rest of the week canceled by the yom tov. However if by accident or on purpose he does not mourn during that hour, and definitely if he was unaware of the death until after yom tov, then he has to mourn for 7 days after yom tov.
B. Basic laws of mourning include no working, no showering or laundering.
C. There is a prohibition of working and laundering during Shabbos, yom tov even on chol hamoed for the most part.
Answer: Since one is practicing acts of mourning during the yom tov by not laundering or working then it counts for both the yom tov and mourning and that is why mourning is canceled because it was fulfilled to an extent during the actual yom tov.