This is a great question. For those who are unfamiliar, and in areas where airspace is complex, it’s sometimes useful to look at the VFR Flyway Chart. This is the one on the back of FAA Terminal Area Charts.
The dashed blue outlines surround the crazy cutouts that are Seattle’s Class D airspaces.
Why does KBFI stick into the KSEA Class B?
Class D airports, or at least those that don’t exist entirely within more restrictive airspace, will always have a ceiling. This is because there will be sections that are not contained within the Class B (or C) areas. For those areas, we need to know how high the Class D airspace goes.
If there is Class B and Class D airspace in the same place, which is it?
This one is in the AIM, 3-1-3:
Hierarchy of Overlapping Airspace Designations
a. When overlapping airspace designations apply to the same airspace, the operating rules associated with the more restrictive airspace designation apply.
So, if you’re over the I-90 bridge at 1900 feet, you’re in KBFI Class D. If you’re at 2100 feet, you’re in KSEA Class B.
Why does KSEA have weird class D chunks?
This one is easier - because Class B doesn’t always go to the surface (only at the core), but there is still a need to filter out traffic from the immediate airport environs. Because two-way communication is required, pilots will need to talk to the tower before getting too close (~5SM) to the airport.
Another factor is that Class D centers on the airport; Class B is centered on the SEA VOR, and they are not coincident. This is so that the rings could (when it was circular) be defined with DME.