Polynomial-Time Algorithms for Counting and Sampling Markov Equivalent DAGs