Tons of practice is all it takes. You're trying to master a technical skill here, not really a musical one, so don't worry about making your notes on tempo or even playing anything remotely interesting musically.
I just worked on open As until I could pump them out without making the E string ring. Then D, then G and so on. You're not making music here, so don't worry that it's entirely musically uninteresting.
Then, work on something basic. Major scale all the way up one string and back down. Then work it across the strings. Focus only on cleanly attacking
only the note you're wanting to play. Before too long, you'll develop a way of doing it that fits you and the way you play. If you find something in the way you're moving your hand that gets in the way of running notes up and down a single string, or across strings, now is the time to change it.
Congratulations. You've learned the basic mechanics now. It's like learning how to drive a car. The technical end is the boring part. Now see what interesting places you can drive... what interesting music you can make now. Learning the technical part is only good if you can use it in the service of some good music.
One hint for you from my own way of doing this: Despite getting pretty good at not hitting adjacent strings, I found the strings above where I was playing still had a tendency to ring now and again. I adjusted my technique so that the ball of my thumb and/or the side of my palm can help mute those upper strings for me when needed.