I wonder how to avoid the buzzing sound when switching between chords .
It could be the set up of the guitar, but it could also be the fact that you let the pressure off the strings too slowly and for too long. This gives the sound of a well pressed down string a chance to buzz. Try to hold on to each note, or each note of a chord, until you're just ready to change to the next. Then get there as quickly as you can. It won't happen straight away, but with practice, it'll get smarter. A good idea is to hammer a chord shape onto the fingerboard. Easy with chords such as E, Em, A, Am, B7. This means that your fingers get used to all going down together, rather than in installments, leaving a finger on the last chord, which buzzes as you struggle to move to the new position.
Most often caused by fingers dragging across the the strings when changing chords. The solution? Practice, practice, practice.
It takes a while to build up any muscle memory, and considering each chord shape is a muscle memory in its own right, it takes a lot of practicing to switch between your whole chord repertoire seamlessly.
Well first of all, kudos to you for hearing the problem and wanting to improve. So the overall answer of course is the speed at which you change fingerings, and this is something that will improve naturally over time as long as you continue to HEAR the problem and focus on improving. But there are also techynical adjustments and tricks you can use. There are many ways to make any given chord, and multiple ways to finger the same chord. Look for chord and fingering variations that minimize the number of finger changes a chord transition requires. Or, just as useful, the ways to retain the same finger position "shape" ans you transition. An example there might be making a C chord with C,G and E fingered on the bass strings, when you know the next chord will be an F-barr. In that case the three fingers on the bass strings retain their shape and move to the next higher strings as a group, while the first finger (that was fretting the middle C note) switches to a BARR at the F position. Together this maakes for a less complex transition that you'll gain expertise in quickly, compared to making the same chord change using the more "standard" 3 finger "C" chord. Another trick, guitarists often also use "drone" notes that can be sustained over multiple chords, which can help mask some buzz. There are other shortcuts, and there is no such thing as "cheating". But generally the faster you learn to make transitions the less buzz you'll have. Give it time and keep practicing.
Oh... and use a metronome too! Though its impossible to do this 100%, it will help you focus on the "ideal" of trying to make all finger changes AND the next strum, all at the instant of the metronome "tick".