The instruction that was actually given

Read carefully what this does and does not say. It does not tell you to stop looking upward, and it does not treat the upward look as a sin. It tells you to add the other direction to a measure that has become one way.

Qur’an and Sunnah

Narrated Abu Huraira:Allah's Messenger (ﷺ) said, "If anyone of you looked at a person who was made superior to him in property and (in good) appearance, then he should also look at the one who is inferior to him

Sahih al-Bukhari 6490graded sound, sahihaynfull report

Abu Huraira reported that Allah's Messenger (ﷺ) said:When one of you looks at one who stands at a higher level than you in regard to wealth and physical structure he should also see one who stands at a lower level than you in regard to these things (in which he stands) at a higher level (as compared to him)

Sahih Muslim 2963graded sound, sahihaynfull report