I can't see where you get 20 million light years from. They are 2.5 million light years apart now, and will collide in about 5 billion years time. This suggest perhaps that when they formed around 12.5 billion years ago, they might have been, at most, 9 million light years apart.
Both galaxies are of mass $\sim 2\times 10^{42}$ kg. If they were 9 million light years apart, then each would feel an acceleration of about $2\times 10^{-14}$ m/s$^2$. Even were that acceleration to stay uniform (it of course increases as $1/r^2$), they would cover half the distance between them in just 70 billion years. Thus merger on a timescale of about the current age of the universe is not unexpected.
A more general way of thinking about it is in terms of the typical gravitational dynamical timecscale $\tau \sim (G\bar{\rho})^{-1/2}$, where $\bar{\rho}$ is the average density of a structure. The local group of galaxies is dominated by Andromdeda and the Milky Way, and is about 10 million light years across and contains about $5\times 10^{42}$ kg, so $\bar{\rho} \sim 10^{-26}$ kg/m$^{3}$ and $\tau \sim 40$ billion years. Again, this suggests a merger after $\sim 16$ billion years of evolution is not unexpected.