Unless you have a Basenji (a non barking breed) then barking, whining, howling and growling are a dogs natural way of expressing themselves and communicating. To expect them to not bark is like expecting a child to not talk.
Dogs do not bark just because they can, nor bark just to annoy us though it may seem that way at times (although if you are not the owner then a constantly barking dog in the neighbourhood can be annoying!). If barking is a problem you need to start by understanding why your dog is barking then address the issue.
They may bark as a warning of danger (to make something they are afraid of or don’t like go away) or alert (they have seen or heard something out of the ordinary or a stranger passing the home). Take some simple measures to manage the environment so the barking is not triggered and reinforced. Prevent them seeing outside or hearing outside noises which encourage barking. If they bark to alert then once you are alerted interrupt them (I use “Thank you!”). Follow with a cue for a rewardable behaviour, such as a sit. They may bark for attention so remove or withold what they want until quiet. If they bark from fear then they need professional help to be desensitised to things they may be afraid of. They may also bark from distress and anxiety (common in dogs anxious when left home alone). Some may bark in play and excitement, or in response to other dogs barking. Or out of frustration, or boredom (to amuse themselves) and barking can become a habit like chewing your nails. They may even yelp with unexpected pain or in senility. Avoid punishing the bark using water or other sprays, rattling bottles or shouting at them. This could make a negative association with you or whatever the dog barks at making it more fearful and shut down or aggressive.