Rational points in periodic analytic sets and the Manin-Mumford conjecture