It looks as if William was illegitimate and given his father’s surname of Scott, which was common practice in Scotland. Can’t see a baptism on FamilySearch or ScotlandsPeople, so perhaps he either wasn’t baptised or his baptism record hasn’t survived.
The information on the marriage and death certificate is whatever the registrar was told, so isn’t always correct. It depends on what the person getting married, or the informant for a death, knew or was willing to say.
I think this could be William and his mother in 1861. If so, Mary had a second illegitimate son.
1861 Census:
Auchterarder Road, Dunning
Mary Stewart head age 34, field labourer, born Madderty, Perth
William Scott son age 8, scholar, born Crieff, Perth
John Cameron son age 5, scholar, born Trinity Gask, Perth
On FamilySearch there is a baptism for John Stewart in 1855 at Trinity Gask, mother Mary Stewart, no father named. Could be worth look this up on ScotlandsPeople as it was the first year of civil registration, and birth certificates for that year contain a lot of detail.
This looks like Mary in 1851, a servant with a Scott family:182
1851 census:
Montague Mill Farm, Kilspindie, Perthshire
Thomas Scott head age 50, farmer of 100 acres, born Auchtergarven
Jean Scott wife age 49, born Methven
Mary Stewart servant age 24, born Madderty
Perhaps David Scott was related to Thomas Scott?
1841 census:
There’s a Mary Scott age 15 and a Helen Scott age 15 (therefore their ages were 15 to 19) at Auchtergaven in the household of Robert Scott at Caerny Hill, Auchtergaven, plus Robert’s wife and children. Worth looking this up on ScotlandsPeople to see the actual image. Mary and Helen could have been servants or relatives.
FamilySearch has a baptism for Mary Stewart in 1826 at Madderty, parents Alex Stewart and Ann Nish.