Why did she say such a thing? I think there are several possibilities: one is that your girlfriend is insecure and feels that she has many shortcomings and deficiencies compared with you. She thinks that one day you will abandon her because of these shortcomings and deficiencies, so she chooses to leave voluntarily to avoid this kind of trauma. One is that your girlfriend thinks you are too good to her, too good, so that she feels that she can't see your bad things at all. And she wants to be with a more versatile person, which has both good and bad aspects. She may think that such a boyfriend is more real and will be more comfortable to get along with. Another is that she has no feelings for you and wants to break up with you, but you have been very kind to her and she can't find a reason to break up. At the same time, she doesn't want you to be hurt too much, and her own guilt will be less.
These are all hypotheses, and the most important thing is to prove them yourself, but be careful, communicate calmly and don't bring negative emotions.