Throughout the series, Phineas and Ferb spend the summer constructing rollercoasters, treehouses, time machines, and backyard beaches. Simultaneously, Dr. Heinz Doofenshmirtz manufactures outlandish "-Inators" intended to exact petty revenge on Danville or overcome deep-seated childhood trauma (such as being replaced by a garden gnome or having neither parent show up to his birth). The narrative tension rests on the certainty that Perry's defensive actions against Doof's inventions will generate accidental physical chain reactions that obliterate the boys' projects just as Candace brings her mother into the backyard.
In Phineas and Ferb the Movie: Across the 2nd Dimension, the central dynamic ruptures when the boys accidentally assist Doofenshmirtz into a parallel totalitarian dimension ruled by an alternate, genuinely ruthless Doofenshmirtz. Perry reveals his identity to save them. The boys feel betrayed by years of secrets, but eventually team up to liberate the city. At the end, to keep Perry from being relocated by O.W.C.A., the boys and Candace willingly submit to having their memories wiped, preserving their status quo.
In the original series finale, "Last Day of Summer", Candace faces the end of summer vacation. A time-loop triggered by Doofenshmirtz's "Do-Over-Inator" begins unraveling reality and swallowing hours and people out of existence. When Phineas and Ferb vanish into the rift, Candace realizes her obsession with busting them is meaningless compared to her love for them. Candace, Perry, and a reformed Doofenshmirtz restore the timeline. Doofenshmirtz formally renounces evil, finding peace with Vanessa and Perry. The boys assemble with their friends under the backyard tree, perform a farewell anthem thanking the audience, and head inside as summer concludes.