At least for the water leak scenario, the best approach is to put a drain pan under any appliances that could leak (laundry machines, dishwashers, water heaters). The drain pan should itself drain to a pipe.
Ideally, a water leak sensor should be used help to catch a slowly failing appliance so you can repair/replace it before it does major damage, not preventing it from doing damage in the first place due to a sudden major leak.
Ideally, a water leak sensor should be used help to catch a slowly failing appliance so you can repair/replace it before it does major damage, not preventing it from doing damage in the first place due to a sudden major leak.