If you are not the owner of these dogs, there is not much you can do.
There are many potential reasons for this kind of aggression. The dogs could have been socialized in a bad way, they probably received too little training and if dogs are left to themselves without regular human contact - either because they are guard dogs or live only with other dogs - they simply don't know how to properly interact with humans.
The way you describe them - they snap and bark at anyone, even their owners - makes me assume they are guard dogs who live outside all the time. This often leads to extreme guarding behavior, because it's the only thing the dog knows and there's nothing else to do. The snapping is a very clear warning sign that they don't want to be touched. Please don't insist on petting them or they might actually bite you. And don't try to touch them when they are eating, they might think you want to steal their food and bite you.
One thing you can try is having a few treats in your pocket. That could be regular dog food, dog biscuits or even dry bread. When you visit your friend, act as if you ignore the dog, but hold one of those treats in your hand for the dog to take. After a minute or two, you can hold another treat in your hand, but ignore the dog when he takes the treat. That way he connects you with something positive and likes you more. You need to repeat this several times to become friends with the dog. And this is no guarantee that the dog will allow you to touch him.