When power flows through the first circuit (1), it activates the electromagnet (brown), generating a magnetic field (blue) that attracts a contact (red) and activates the second circuit (2). When the power is switched off, a spring pulls the contact back up to its original position, switching the second circuit off again.
This is an example of a "normally open" relay: the contacts in the second circuit are not connected by default, and switch on only when a current flows through the magnet. Other relays are "normally closed" and switch off only when the magnet is activated, pulling or pushing the contacts apart. Normally open relays are the most common.
Here's another animation showing how a relay links two circuits together. It's essentially the same thing drawn in a slightly different way. On the left side, there's an input circuit powered by a switch or a sensor of some kind. When this circuit is activated, it feeds current to an electromagnet that pulls a metal switch closed and activates the second, output circuit. The relatively small current in the input circuit thus activates the larger current in the output circuit:
a.)The input circuit is switched off and no current flows through it until something turns it on. The output circuit (blue loop) is also switched off.
b.)When a small current flows in the input circuit, it activates the electromagnet, which produces a magnetic field all around it.
c.) The energized electromagnet pulls the metal bar in the output circuit toward it, closing the switch and allowing a much bigger current to flow through the output circuit.
d.)The output circuit operates a high-current appliance such as a lamp or an electric motor.
https://www.electrikals.com/products/rmc-havells/control-relay-cosmic-star?mid=28&cid=750&rid=690&page=1&pagesize=30