Hmm. That does look strange - John vs William
Noting that the baptism in 1757 to William D and Margaret S was in Old Deer, and the three to John D and Margaret S were in New Deer, I hate to have to say it but I don't think you can rule out there being two Margaret Sangsters, one married to John in 1757 and the other married to William. The alternative is that John decided to call himself William while he was in New Deer. Either of those options looks a bit odd.
There are no baptisms of children to James D and Margaret Gall after Mary in 1781, so it is possible that either your James D who married Margaret Ramsay or the other James D who married Jean Taylor was Margaret Gall's widower (or even the one who married Helen Hay). You'd need to see if Mary's baptism gives her father's occupation, and compare that to what you already have.
I notice that James D and Margaret Ramsay named children May and George, and that William D and Margaret Sangster had a George and a Marjory. May and Marjory are used interchangeably, so that looks potentially interesting.
However WT says that John/William's son James married Jane/Jean Taylor, and we know that Jane/Jean Taylor's husband can't also be Margaret Ramsay's husband.
What places and occupations are associated with which of the baptisms?
I see that WT has a death for Mary in 1827 in 'Aberdeenshire' (no parish mentioned - instantly suspicious) which is not matched by either the deaths/burials on Scotland's People, or the ANESFHS MI index. Also that the source of this is given as Ancestry.com. Therefore it is not to be trusted.