Taken from Wild Mass Guessing of Phineas and Ferb from TV Tropes.
Linda became a millionaire thanks to her music career, but she really wanted children and couldn’t find a suitable mate until Lawrence (She tried with Dr. Doof with nefarious consequences and decided not to try for a looong time). So she went for sperm donation.
Level 100-size ego Roger Doofenshmirtz was of course a prolific sperm donor. His profile said “Very charming pillar of the community” or something like that. So, Linda went for it, twice.
Roger knows that Phineas and Candace are his children. Picking Candace as mayor for a day was a BatmanGambit to meet her, too bad the space continuum had to change.