Act 3 is pretty much just a Boss battle against Monika. And she simply wanted to use Yuri’s unorthodox interests and awkwardness to make her seem unappealing. Sayori and Yuri die as a side effect of Monika tampering with them – she originally wanted Sayori’s depression to simply prevent her from confessing to the MC in the first place, out of fear of rejection.
So, in a desperate bid to try and rescue the happy ending she tried to give you, she attacked Sayori. Monika recognized that you, the Player, deleted her likely for ALL the other girls, not just Sayori. She will then force the game to close and delete the other character files, including herself. If Monika’s character file is deleted (as explained in Monika’s Ending) before starting a new game in Act 1, Sayori appears to realize that she is trapped in a game. You might be interested: Best poetry authors What happens if you delete everyone but Monika?