This might depend to some extent on where you live in the US.
If you live in an area where snow and ice are not an issue, then the 2WD version with lower odometer miles is a clear-cut winner of this competition.
On the other hand, if your area does get nasty winter weather, there will be days when you will be glad that you have AWD.
For me, a major factor would be the maintenance records of these two vehicles.
A vehicle that accumulated only 18k miles in ~4 years could have already begun to experience an engine sludge problem if it has not had its oil changed at least 4 times already. Personally, I would have changed the oil on that vehicle at least 6 times so far, based on the elapsed time factor.
And, a vehicle with 58k on the odometer could also suffer from various mechanical problems in the future if it has not been maintained properly. People who buy cars without maintenance records are taking a very big chance with their own wallets!
Can you verify through documentation that these two vehicles have been maintained at least as well as Mazda specifies? Don’t take anyone’s word for it. Only accept documentary evidence of their maintenance.