This ability is thanks to the intrinsic conduction system, which is defined as the internal regulating system that causes the heart to contract rhythmically.
Rhythmically contracting and relaxing their muscles, they draw water in and out over an internal lung-like structure called a respiratory tree that extracts oxygen from seawater.