How does $\frac{mv^2}{r} = \frac{GMm}{r^2}$ work if both planets attract each other? According to this and this, both posts describe the fact that the earth and the moon are attracting each other due to gravitation.
The gravitation force is $\frac{GMm}{r^2}$.
However, I am not able to understand why this is equal to $\frac{mv^2}{r}$, this force describes the centripetal force needed to keep an object to orbit around a fixed center with distance $r$, mass $m$ and velocity $v$. But in the case of the Moon and Earth, the Earth is also experiencing a force due to the Moon. The Earth is also moving towards the Moon. The distance doesn't seem to be fixed.
Can you tell me what I am thinking wrong?
 A: The equation you wrote down only holds for uniform circular motion (with constant radius and velocity).
$\frac{v^2}{r}$ is the inward acceleration, when a body goes in a circle of radius $r$, with constant speed $v$. So, from Newton's second law, we know that an inward force $\frac{mv^2}{r}$ must act on it.
This inward force is gravity, whose magnitude is $\frac{GMm}{r^2}$. Therefore, these two must be the same.
In this model, both Earth and Moon undergo uniform circular motion around their center of mass (which lies inside the earth, as it is much heavier than the moon).
$r_{moon}$ and $r_{earth}$ are distances of Earth and Moon from the center of mass.
And, $r_{moon} + r_{earth} = r$, the distance between them.
So, for Moon, $\frac{mv_{moon}^2}{r_{moon}} = \frac{GMm}{r^2}$.
While for Earth, $\frac{Mv_{earth}^2}{r_{earth}} = \frac{GMm}{r^2}$
The velocities of earth and moon are related by the fact that they have equal angular speed (which is required for equal time periods).

(Image source Wikipedia)
In the actual earth-moon system, the radius of orbit is not constant. Up to a certain accuracy, both earth and moon go round their center of mass in elliptical orbits. Then, there are perturbations from this orbit due to the gravitational attraction of other planets, and the sun. Also, the system is constantly losing energy due to tides.
A: The two bodies are not "moving towards" each other. Rather, they are both orbiting around a common barycentre - the centre of mass of the system. So the Earth "wobbles" around this point.
Also, note that the $mv^2\over{r}$ equation is actually just the equation for the force required to keep a body of mass $m$ moving in a circle of radius $r$ at a speed $v$. It works for a car driving round a circular track, for instance.
Using it in a gravitational orbit you have to consider the mass difference between the primary and satellite.

*

*For an artificial satellite, which is tiny compared to the Earth, you can measure $r$ from the centre of the Earth.

*For the Moon, you have to use the radius of the orbit from the barycentre - not from the centre of the Earth.

A: 
But in the case of the Moon and Earth, the Earth is also experiencing a force due to the Moon. The Earth is also moving towards the Moon. The distance doesn't seem to be fixed.

The force the bodies exert on each other is taken care of in Newton's formula (both the mass of sisters Earth and Moon are present).
There is, in the case of an ideal circular movement, an exact cancellation between the gravitational force and the centrifugal force. Only $m$ appears in the expression for the centrifugal force (and thus, not $M$) because this force only can be applied to one mass, not two (unless you consider the two-mass system rotating around another mass). One could also use $M$, in which case $r$ stays the same but $v$ will be different.

