Dunfermline is in the historic county of Fife (aka Fifeshire) and the modern Unitary Authority of Fife.
Wikitree location: Dunfermline, Fife, Scotland
Dundee is in the historic county of Angus (aka Forfarshire, an earlier name for the same area) and the modern Unitary Authority of "Dundee City"
Wikitree location: Dundee, Forfarshire, Scotland.
It is extremely likely that Thomas MacDonald is a very common name and there may be tens of Thomas MacDonalds with the same birth year who were just born in the various parishes of Dundee (St. Andrew, St. Peter etc.)
As far as sizes go it is probably most helpful to think of two Scottish counties as being the same interrelationship as two US counties within the same state, especially a state with a small area such as Massachusetts.
The historic county of Fife was actually quite a large territory in relative terms to the others. And although the counties of Fife and Forfarshire are adjacent to one another (the River Tay being the boundary), Dunfermline is actually on the south side of the county near the River Forth (Wikipedia says the city centre is approx. 3 miles inland).