There are several exercises you can do to build independence of the fingers. It is a long process.
A set of left hand classical guitar exercises (which is just as good on the electric) can be found in Pepe Romero's book. The easiest involves doing trills with two consecutive fingers while keeping all other fingers planted on the next string.
Example:
Start with the index finger on the first fret of the low (pitch) E string and fingers 2 through 4 on frets two through four on the A string.
Lift your second finger up and place in on the second fret E string (it should have started on A), "hammering" it down. Then pull off to play the first fret. You are playing F and F#. Play the sequence (F#, F, F#, F, F#, F, F-) where F- means hold twice as long as the other notes.
The important thing is to do this with fingers 3 and 4 firmly planted on the A string.
Then, keeping fingers one and two on frets 1 and 2 of the E string lift the 3rd finger and do the same things with notes G and F#.
Then lift the pinky and do G# and G.
At this point you shift to the fourth position, index finger on G#, and repeat the entire pattern.
Move all the way up until there is no where to go.
Do the same on every other string.
I think the author also has you going back to first position.
The key to this exercise is to NOT move the other fingers while you hammer-on and pull-off with a single finger. At first you may feel like you have to squeeze but in time you will realize that you can execute this movement without squeezing. Then gently release the pressure so that you are only touching the strings but not pressing down. Then lift.
In reality if you play this SLOW enough you should NEVER have to squeeze to keep the other finger down. I think most instructors would scold me for even suggesting it. But the key is that as a beginner you don't have the correct muscle memory for what is feels like. Speed begets tension in beginners. What you need to do is practice basic exercises slow enough that you can hold the correct position, drill it, then try going fast.
Another exercise you can do WITHOUT the guitar is to tap one finger on the table top while keeping the others down. This is basically the same exercise as I just described.