Harry just survived Avada Kedavra which wasn't supposed to happen. At this point, she started to believe that the prophecy is going to be true. Then, she asked about Malfoy just to realize Harry was a good guy and she was following the wrong side. So, she changed side.
Note: The answer is purely based on normal psychology thing.