It depends exactly what the music is asking for. If that is a quick section not calling for any changes in hand position then leaving the finger covering that fret is the best solution.
Lowering the pressure on a fret will attenuate the note, so here you have a choice - either maintain the notes and allow them to ring out or soften them. Typically if you take chord across the neck of the guitar and you're playing within that letting them ring is the best solution, in some quick/complex section keeping notes held will make the individual notes hard to distinguish. In your example you aren't needing to shift you hand position and are playing across a couple of strings, so you can keep your individual fingers covering the notes required.
Just as an aside to your problem of hitting multiple strings: the ability to selectively mute/open strings is a vital skill and your fingers will quickly build up the agility and muscle memory to play such sections without interfering with other strings too much. In addition to the section you have posted playing scales in a set position in various orders is another way of working on the speed and precision needed - taking 1-8 to be the notes combinations like:
1,3,2,4,3,5,4,6,5,7,6,8
Or in a basic tab notation:
G|--------------------------|
D|----------------2---4-2-5-|
A|-----2--3-2-5-3---5-------|
E|---3--5-------------------|
Which is simply a G Major scale but played in a specific pattern. You can make these as complex as you want, but always check whether you are catching other strings and that each individual note is ringing out clearly. Exercises like this will quickly help you fingers adjust to the guitar, and I'll use them as warm ups before gigs as well as ways of improving my own play. Specifically for the chords I would consider holding down a certain root note and that playing other notes around it, constantly checking that every note is ringing out clearly. If a note is a dud then don't assume you will get it right next time, but look at why it's not worked and adjust immediately. The same is true when learning a new chord - always be extremely picking about making sure everything rings correctly and (importantly) when you specifically want to allow/disallow it.
Ultimately whilst exercises like these can be dull and I will avoid them to go an jam a song repeatedly they are extremely useful in the long run.