First off NASA thought it might hit in 2029, but it was a 1:233 chance that it would. They do know now that Apophis will not, or is extremely unlikely to impact Earth.
The first announcement of Apophis was on December 24, 2004. So it only took 3 days for them to conclude that the original calculations were off because of the incomplete/inaccurate information that they had at the time.
On December 27, 2004, in the afternoon, a precovery increased the span
of observations to 287 days which eliminated the 2029 impact threat.
The cumulative impact probability was estimated to be around 0.004%, a
lower risk than asteroid 2004 VD17, which once again became the
greatest risk object.
Doing the calculations without all of the correct information is what led to the inaccuracies.
Criticism of older published impact probabilities rests on the fact
that important physical parameters such as mass and spin that affect
its precise trajectory have not yet been accurately measured and hence
there are no associated probability distributions....Small uncertainties in the masses and positions of the planets and Sun
can cause up to a 23 Earth radii of prediction error for Apophis by
As to why astronomers/scientists can roughly calculate DA 1950 so far out there...
That 1950 DA has one of the best-determined asteroid orbital solutions
is due to a combination of:
an orbit moderately inclined (12 degrees) to the ecliptic plane (reducing in-plane perturbations)
high-precision radar astrometry that is more accurate than visual-wavelength measurements
a 60-year observation arc
an uncertainty region controlled by resonance
It as been seen twice (1950 & 2001) and been able to record how it moved. We will see it again in 2032 and be able to more accurately calculate if it may hit or not. As of right now the uncertainty is caused by several things.
If 1950 DA continues on its present orbit, it will approach near to
the Earth on March 16, 2880. However, over the intervening time,
its rotation will cause its orbit to slightly change as a result of
the Yarkovsky effect. Available radar and optical data suggest two
possible pole directions; one trajectory misses the Earth by tens
of millions of kilometers, while the other has an impact probability
of roughly 1 in 300
If it continues uninterrupted there are two paths that they think it will take. One will miss earth by millions of kilometers and the other only has ~ a 1:300 chance of striking Earth.
For a much more detailed description you can check out this NASA PDF detailing the probabilities of the DA 1950 collision.