In sefardi communities, it is very common for parents to kiss their children, and for men to kiss each other, e.g., as congratulations after an alyah laTorah. That surprised me and I had looked up the halacha.
R Ari Enkin writes here on the topic and explains it according to the Kaf Hachaim ruling
It is permitted, however, to kiss the hand of one's parent or rabbi
should that be the local custom, as doing so is a sign of honor and
respect rather than affection (Yechave Daat 4:12, Kaf Hachaim 151:6,
Or L'tzyion 2:45:35, Ishei Yisrael 11:footnote 64). In fact, the
practice of kissing the hand of an elder in the synagogue is one which
dates back to Talmudic times (Avoda Zara 17a; Rashi). As such, we see
that giving a kiss in a religious context is often more of a
ceremonial gesture than an affectionate one.
According to a number of authorities, the prohibition against kissing
in the synagogue applies exclusively to kissing one's children and not
to others. This is because the feelings that one has for one's
children are unlike those for any other person (Kaf Hachaim, OC
98:10) [...] Conversely, kissing any other person following an aliya
or other synagogue honor, as is the custom in many Sefardic
congregations, would be permissible according to this approach (Ben
Ish Chai; Vayikra 11)
See the original for further details
I remember reading (in R Moshe's biography I believe) that R Moshe Feinstein used to kiss his grand-children in shul as he held that the prohibition applied only to direct children.
R Chaim Cohen writes further that
R’ Avraham Yitzchak Kook (Orach Mishpat OC 22) writes that this
prohibition applies to kissing other family members and friends, too.
The Ben Ish Chai (Vayikra 11) writes that while one shouldn’t kiss
one’s young children in Shul, the sefardi minhag of kissing the hand
of a Talmid Chacham is commendable because it is done out of respect
rather than personal affection. Likewise, one may kiss one’s father or
Rabbi after being called up for an aliyah where that is the accepted
practice (See Kaf Hachaim OC 151:6). R’ Ovadia Yosef (Yechave Daas
4:12) explains that showing them kavod is a form of honouring Hashem,
just as one must stand for them, even in Shul. One shouldn't kiss any
other relatives who one isn't obligated to honour, however.
See also here and here for further views.