Twilight never sees this coming as the dark magic from the device corrupts her. This was planned by Princess Dark Matter, who found the device in the human world. She repaired it, and went back to Equestria, so she can leave it at Twilight's castle for the princess of friendship to wear it.