On gradient flows of nonconvex functionals in Hilbert spaces with Riemannian metric and application to Cahn-Hilliard equations