When the switch is on, the circuit is completed and current flows. The electromagnet becomes magnetised and hence attracts the soft-iron armature and at the same time pull the hammer to strike the gong. This enables the hammer to strike the gong.
As soon as the hammer moves towards the gong, the circuit is broken. The current stops flowing and the electromagnet loses its magnetism. This causes the spring to pull back the armature and reconnect the circuit again.
When the circuit is connected, the electromagnet regain its magnetism and pull the armature and hence the hammer to strike the gong again. This cycle repeats and the bell rings continuously.