Schrödinger symmetry in cosmology and black hole mechanics