Mathematical Structures of Statistical Mechanics: from equilibrium to nonequilibrium and beyond