In the event of a breach, nowhere on the ship is safe. The same is true with modern-day nuclear vessels.
The reason nuclear vessels have the reactors separated from the engineering compartment is due to the nature of its shielding. Reactors are shielded through physical means using various metals including iron to limit the amount of radiation that escapes. Even the most advanced physical shielding still allows harmful radiation to get through, so crew can only spend so much time near the reactor without experiencing negative effects. Additional segmentation of the reactor sections and engineering section further limit radiation exposure.
Warp reactors, on the other hand, use magnetic containment, whereby the harmful radiation and other particles are contained via a non-physical mechanism. They have to use magnetic containment since there's simply no material strong enough to contain so much energy.
The actual materials of the warp core do not contain its energy, rather a veritable force field does. Given this fact, its not necessary to keep the reactor separate from the crew since there's both no physical material strong enough, nor is there the need due to magnetic containment.