I found the cause.
I train 7 treants simultaneously and if I have the quest active and the treant training is finished they count torwards the quest.
Edit: Still 7/4000 after refreshing.
Edit 2: further testing with training 2 dancers and 1 archer and they count too, so I'm at 10/4000 now.