Realization theory for automata in categories