We design for this using pressure vessels to protect the components and, in other cases, oil-compensate when the internal electronics are pressure tolerant but need to be isolated from the seawater. These are both common techniques for design in underwater robots.