Sorry, Mohammed. You've misunderstood the rules for parallel structure. If you say, "I prefer to walk rather than driving," that is faulty parallelism. It should be changed to: "I prefer walking rather than driving." There is no rule in English that requires the repetition of unnecessary prepositions. However, as an English learner, if you wish to repeat those prepositions in order to be sure that you are not making a mistake, there is no rule against it.