In the context of Markov processes, both in discrete and continuous setting, we show a general relation between duality functions and symmetries of the generator. If the generator can be written in the form of a Hamiltonian of a quantum spin system, then the "hidden" symmetries are easily derived. We illustrate our approach in processes of symmetric exclusion type, in which the symmetry is of SU(2) type, as well as for the Kipnis-Marchioro-Presutti (KMP) model for which we unveil its SU(1,1) symmetry. The KMP model is in turn an instantaneous thermalization limit of the energy process associated to a large family of models of interacting diffusions, which we call Brownian energy process (BEP) and which all possess the SU(1,1) symmetry. We treat in details the case where the system is in contact with reservoirs and the dual process becomes absorbing.