How and when did a dedicated immune system evolve?
Immunity has probably evolved more than once as it is completely necessary for survival.  You might even argue that defenses such as antibiotics and predatory behavior are immune defenses for single celled creatures.  

As you point out, plants have a different immune system than animals do.  Insects do too.  They don't have innate immune memory which many animals have, where pools of cells embody the immune response to a specific antigen.  (i.e. encode for a specific immunoglobin or a tCell Receptor variant).  

I found this reference that this appears to be the collective property of jawed vertebrates.  Even so, there are many late innovations in the immune system, where reptilian and mammalian immune responses vary substantially. 

Its not clear to me whether other animals have the insect system. Animals that branched off before insect lines such as radiates probably have their own way of dealing with immune response.  That's just a guess though.