If a positive number nnn leaves remainder 2 when divided by 7, we can write
n=7k+2n=7k+2n=7k+2 for some integer kkk. Then

3n=3(7k+2)=21k+63n=3(7k+2)=21k+63n=3(7k+2)=21k+6

When 21k+621k+621k+6 is divided by 7, the term 21k21k21k is a multiple of 7, so it leaves remainder 0, and the remainder comes only from 6. So, when 3n3n3n is divided by 7, the remainder is 6.