Equilibrium Propagation: the Quantum and the Thermal Cases