Zinc can form a dense oxide film with oxygen, thus isolating iron from water and oxygen.
But if you put zinc blocks on the iron boat, it is based on the principle of primary batteries.
Because zinc is more active than iron, it will be preferentially consumed in seawater, thus protecting the hull from damage.