Dunn is a poor defender in the national league. He's playing on the nationals, who not only will be out of the playoffs by the deadline, but will probably looking for some prospects for Dunn, who is on his last year of his contract. He also costs 1/5th of the Nationals total salary. Dunn would prefer playing on a contender.
A-gon for the Padres is half the price, a hometown favorite and local native, plus he has another full season after this one, actually hits for average, and has more long term appeal. San Diego has said multiple time that they won't trade him unless blown out of the water, which isn't quite the case with the Nationals.