Equilibrium and out of equilibrium phase transitions in systems with long range interactions and in 2D flows