Both are perfectly ok in this context. The words are synonymous, with a slight difference in nuance: „a alerga” usually refers strictly to the physical action of running (for instance, in a marathon), whereas „a fugi” usually (but not always) implies you are running away from danger.
You can say „am alergat la maraton”, but you can definitely not use „a fugi” in this context.
copilul aleargă spre ei. = the child runs towards them.
copilul aleargă spre ea. = the child runs towards her.
copilul aleargă spre casa ei. = the child runs towards her house.
so ei has two meaning and duolingo software will not always be able to tell you which one is appropriate.