It's because you feel lonely and you didn't found a person to love so your subconscious creates this someone in your dreams. Because you have desires you will create someone perfect in your dreams and that helps your brain release endorfines and not get depressed of being lonely or not feeling attractive enough.