Similar story when I visited Nairobi with my then-partner: stayed in a fenced compound with guards; and when we visited my partner's friend, on the bus to her place we passed a supermarket which was guarded by someone holding a light machine gun.
This was shortly after the Westgate Shopping Mall attack. https://en.wikipedia.org/wiki/Westgate_shopping_mall_attack
That was probably a cop in plainclothes. Private citizens don't open-carry as a matter of course in Kenya.