First of all, if the attribution of such a statement is correct towards Prophet Muhammad SAW then it has to be understood that he was addressing people who were in his gathering and had already seen him. A lot of times hadith narrations are not relating any universal facts and must be understood in the context of the event that they are relating.
Secondly, there is no such science that claims that one can only see those in their dreams whom they have already met while awake.
For reference here is the hadith narration:
حَدَّثَنَا أَبُو الرَّبِيعِ، سُلَيْمَانُ بْنُ دَاوُدَ الْعَتَكِيُّ حَدَّثَنَا حَمَّادٌ، – يَعْنِي ابْنَ زَيْدٍ – حَدَّثَنَا أَيُّوبُ، وَهِشَامٌ، عَنْ مُحَمَّدٍ، عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم “ مَنْ رَآنِي فِي الْمَنَامِ فَقَدْ رَآنِي فَإِنَّ الشَّيْطَانَ لاَ يَتَمَثَّلُ بِي ” .
Abu Huraira reported Allah’s Messenger (ﷺ) as saying: He who saw me in a dream in fact saw me, for the satan does not appear in my form.
Sahih Muslim 2266a
https://sunnah.com/muslim:2266a