Even among those men with some good friends, I wonder if there are some who don't really register the times when other men's banter and piss-taking is actually a compliment, wrapped in the socially-acceptable male-to-male communication packaging. Or they pick it up, but don't think of it as a compliment because of how it's presented.
Even at a most basic level, when your mates take the piss, they're also saying "We are close enough as mates that I can insult you, and you'll know that it doesn't mean I don't like you. I like you enough that I want to test and thereby confirm the positive nature of the relationship between us with this apparently insulting interaction, and I'm confident that you like me enough to take it in the right way." Decent blokes will tend to avoid teasing their friends about something they're truly upset about (though they might not realise how deep it cuts when they take the piss out of something like being bald or fat, and might not react well to a man who fails to hide how hurt he is by it).
Often the piss-taking is actively directed at positive things, achievements or possessions. Sometimes that does seem to be an attempt to bring someone down a peg or two, to make sure everyone feels equal, but often it seems to function as a backhanded type of compliment, a way of saying, "I have noticed your big new house with lots of bedrooms and tasteful decor and a dedicated bar/games room/gym, and am impressed by it. I wouldn't feel comfortable telling you that directly, and if I did, I might look like a try-hard or a suck-up, but if I rib you about it you'll know that I've noticed it and consider it sufficiently impressive to tease you about".
IMO (British) male-male friend interaction is way more complex and nuanced than both men and women try to pretend it is. There's a story we tell ourselves that female friends have all these complex overtones and undertones and coded messages buried in everything they say to each other, while men are more simple, just having a laugh yeah? But there's a lot going on in those interactions, which can shade subtly from friendly and supportive to vicious and destructive, with just as much nuance and plausible deniability as the more stereotypically female type of interaction.
("British" because I can't speak for how male friends interact within other cultures; I'm not saying that non-British men necessarily aren't like this, but I don't know that they are, either, IYSWIM.)