Dreams grab from everywhere in your memory - not just what you use regularly, but basically all the junk your mind filed away. that teacher probably made an impression at the time, and even though you haven't consciously thought about her in two decades, the experience got stored somewhere deep. your brain doesn't delete things; it just stops bringing them to the surface until something random triggers them during sleep.
the weird part is what triggers it. could be something you saw yesterday that vaguely reminded you of her voice or classroom, or maybe you were processing some emotion in the dream that needed an old memory to work with. happens to basically everyone - i'll sometimes dream about random kids from middle school and wake up going "where did that come from?" it's less about being weird and more about how sprawling human memory actually is.