Firstly, welcome to the wiki! And the spell was activated because there was a harmonic connection between the cores of Voldemort's and Harry's wand, more specifically that their cores came from the tail of the same phoenix, causing a strange phenomenon to occur. It happened during the time when Harry was duelling Voldemort in the courtyard where Harry was transported to along with Cedric Diggory for accidentally touching a portkey that was disguised as the false Triwizard Cup.
As strange as it sounds, this isn't from google. My masterpiece for a lifetime <3