You’ve got a missing or incorrectly installed flashing. Don’t try to patch it with a "bezel"—the flashing needs to be redone to ensure it's watertight. Modern flashing kits are very user-friendly. Measure the dimensions of your skylight opening and look for a kit from a brand such as Velux or...
Keep the foam—it’s a critical thermal break and weather seal, not just a filler. You shouldn't aim for a flush fit; you need a 3–4mm gap between the skylight and the upstand to allow for thermal expansion and contraction.
If the unit sits directly on the lead, differential movement between the...