A contraction principle for certain Markov chains and its applications