Hmmm. You've got me wondering now.
It is odd that William and Sarah named their second daughter Margaret Swanston if William's mother was Margaret Thomson.
It's also curious, I think, to find a ploughman marrying, in Inverness, a woman from the Black Isle, and then, after having a daughter in Inverness, turning up a few years later almost 200 miles away in Borthwick.
Could there have been two John Youngs married to two Margaret Thomsons, one couple in Inverness and the other in Midlothian?
Might Margaret Thomson have been the second wife of the Midlothian John Young, his first wife being Margaret Swanston? The corollary of that is that would have had to be two different couples, and the record of the second marriage would have to be missing.
I notice also that the trees quoted originally say that John Young was born in 1796, but the Cocker web site says he was born in 1788. Why the discrepancy? Also that Margaret Thomson was born in 1797. What are the sources of these dates?