Any of various enzymes that catalyze the formation of polymers of DNA or RNA using an existing strand of RNA or DNA respectively as a template.