Most instances of contamination in PCR arise from carry over from previous PCR reactions. Thus, by routinely performing PCR reactions with dUTP and treating all new reactions with uracil DNA glycosylase, you render any such contaminants inamplifiable (but not the template, which does not contain dU).
but what about insertion of U in the complementary DNA strands of both the target DNA sequence and the contaminant sequence during amplification cycle. This is confusing for me, could you please elaborate.
One thing is contaminanting DNA (which produces false positives, i.e. a band of the correct size is amplified even in samples where it is not supposed to), and another very different is a product of non-specific amplification (bands of the 'wrong' size appearing in the samples in addition to or even in lieu of the 'correct' band). The former is what UNG treatment is supposed to eliminate, the latter is what I think you are describing, and as you rightly point out, is not solved by UNG treatment.
If my interpretation of your problem is correct, the possible causes are either non-optimal experimental conditions (e.g. annealing temp too low), poor primer design (primers having additional binding sites in the DNA template, for instance), or poor choice of target sequence (for example, choosing a repetitive, polymorphic target sequence).
I have a "contaminating DNA (which produces false positives, i.e. a band of the correct size is amplified even in samples where it is not supposed to)"
I try to sort out the problem by using UNG but i can't understand how it can distinguish between target and previous contaminant.
You mean you have been having false positives and now want to use UNG to prevent them? In that case no, UNG won't help you for the very same reason you are posting here -it cannot distinguish between contaminating and target DNA. UNG is used as a preventive method -if you use it routinely in the lab, then most cross-contaminants will have incorporated dU and will be rendered non-amplifiable by UNG, but if you already have the problem then no, that's not the way to go.