Why is the reason for color different in these two cases?
These at two different scenarios and two different phenomena. Flame color is due to atomic emission and complexes are colored because of light absorption in the solid state and in solution.

In a high temperature flame, an atom is considered to be a free and independent entity. With heat, the electrons in the atoms are excited to higher energy levels. However, selection rules determine where an electron can land e.g. s electron goes to p, p electron can go to d, however s electron cannot go to d.   

In case of transition metals, Hans Bethe (Nobel Prize) developed a theory called called crystal field splitting. In a free gaseous atom, all five d orbitals orbitals have the same energy (called degenerate orbitals), so electronic transitions do not make any sense. It is also forbidden. However in the presence of ligands, the d- orbitals are no longer of the same energy. Electronic transitions are possible within d orbitals. Search crystal field theory if you are interested...