Detailed analysis of the tetraquark potential and flip-flop in SU(3) lattice QCD