Without loss of generality, let $A$ be red. Then $B$ and $D$ can be independently coloured blue or green. If they are different (two ways), $C$ must be red. If they are the same (two ways), $C$ can be either red or the colour that $B$ and $D$ are not.
Similar reasoning applies if $A$ is blue or green. Thus there are $3(2\cdot1+2\cdot2)=18$ ways, not 24 as you calculated.
A generalised problem, counting the colourings of a square with $n$ colours, is given by OEIS A091940.