As a Westerner and more importantly a tourist, you may get a lot of attention. Tourism is a huge industry in Morocco and a highly saturated one. The maze-like medinas are full of shops and restaurants, all of whom employ a worker to stand outside, talk to tourists, and convince them to come inside. Because of the massive competition, sometimes the comments said are meant to get a rise out of you.
Often when you make eye contact with someone, you have given them an invitation to not only start talking, but also, to start walking with you. You can scan the shops as you walk without too much individual attention if you wear sunglasses or keep your focus elsewhere.