When playing a C or a D on the second string, my finger often also touches the first string. I have the feeling that it's bad, but I am wondering why, because if I play a note on the second string, the first string is not important. How important is it to only touch the second string in this case ? And more generally should I pay attention to only touch one string at a time ?
This depends on what you are trying to play. Some day you may want to play one of those notes along with a note on the other string. Then the touching will be bad. There are a lot of subtle manipulations required for playing clean guitar. Sometimes we use our fingers to dampen strings so they don't vibrate with the one we played. Other times we need the other strings to vibrate to get the sound we want. If you were playing an open string C chord then the first finger touching the high e string could ruin your ability to play the e in the melody.
In classical guitar we are sometimes taught in the beginning to play on the tip of our finger and try our best to not let the flesh of the finger touch any of the other strings. This is a good habit to develop early because, IMO, it is difficult. The truth is one can let the fingers drape over the other strings, essentially flattening them out a little. There is no need to keep them square all the time. Most electric guitarists I see do not play with the fingers square. The real point is that you want to be able to change the finger shape at will on a moments notice to perform different functions.
It's not bad at all - unless that other string sounds! In fact, it's a technique most guitarists (particularly electric using overdriven sounds) use all the time. It effectively stops extraneous noises from other strings sounding.
Occasionally, you may want that top string to be still sounding, or leave it clear to vibrate as a sort of overtone from a lower E, for example. So, as long as you don't touch it when it's supposed to be sounding, it's not a problem. All this assumes it's the fretting fingers.