Intimacy is funny. You don’t always know what kind of intimacy will feel painful or threatening until it happens. I agree with your conclusion- the best way to deal with it is to talk with partners about what feels okay or not outside the relationship. Flirting, cuddling, hugging etc.
Your buddy should’ve talked to his wife about his cuddle sessions, and your boyfriend should’ve talked to you about his.