I asked Messenger of Allah ﷺ about looking hither and thither in prayer. He replied, "It is a way of stealing by which Satan takes away (a portion) from the prayer of a person."
سَأَلْتُ رَسُولَ اللَّهِ ﷺ عَنْ الاِلْتِفَاتِ فِي الصَّلاَةِ فَقَالَ هُوَ اخْتِلاَسٌ يَخْتَلِسُهُ الشَّيْطَانُ مِنْ صَلاَةِ الْعَبْدِ