Who, then, is the James D who married Margaret Ramsay? (I wouldn't worry too much about her being shown as Mary on his death certificate. Sometimes Margaret is abbreviated to Marg and then gets confused with Mary.)
He was married in 1784, so he cannot have been born later than 1770, and it is unlikely that he was born after 1760 or so, because (according to his son James' death certificate) he was a blacksmith. That means he had served an apprenticeship, and basically an apprentice can't afford to support a wife so could not marry until he was fully qualified and earning. (What does George's death certificate say his father's occupation was?)
(Noting that James and Margaret named their first son James, I'd expect James' father's name to be James. I'd expect Margaret's parents to be George and Marjory/May. But that's not set in stone.)
There are two recorded baptisms of James Dalgarnos in eastern Aberdeenshire before 1770
Son of John Dalgarno and Margaret Sangster, baptised 1757 in Old Deer
Son of William Dalgarno, baptised 1759 in New Deer
However there are no fewer than five marriages of James Dalgarnos in that area between 1780 and 1795. Therefore there must be more than two James Dalgarnos. Therefore there must be one or more James Dalgarnos missing from the registers of baptism. Therefore you cannot assume that either of these is the one who married Margaret Ramsay.
The first thing I'd do is look at the originals of all the various Dalgarno baptisms, and note things like the parents' residence, father's occupation and the names of any witnesses if they are listed. If, for instance, Helen Hay's husband was a shoemaker, that would be fairly strong evidence against him being Margaret Ramsay's widower, who was a blacksmith.
Then I'd have a good rake in the indexes to gravestones at
http://www.anesfhs.org.uk/databank/miindex/miindex.php and see what they turn up. If necessary get hold of the full inscriptions to find out what the relationships of the various people are to one another. They might be on FindAGrave or BillionGraves, or you might need to get the inscription from one of the published booklets.
I'd also look at all the Dalgarnos listed in the census (use FreeCEN
https://freecen1.freecen.org.uk/cgi/search.pl because it's much more accurate than the transcriptions on Ancestry) and compare that information with everything else. It's a bit late, obviously, to include your James D, but there could be clues to earlier generations.