Clearly, the man who died in Michigan, 1904 is the one born to Andrew Dalgleish and Elizabeth Woodburn (same birthdate).
The baptism clearly says he was 'Natural' son so parents not married. Often children born illegitimately in Scotland grow up with their fathers surname and explains why William is Dalgleish in 1851 census. However, since there was clearly a paternity issue with the father Andrew Dalgleish it was reasonable for him to grow up with his mothers name of Woodburn.
As has already been stated, his mother Elizabeth married a Thomas Gilmour 26/3/1860 Fenwick and agree the 1861 Census doesn't state this his mother was named Janet - she was the only unmarried daughter living at home in 1861 but that doesn't make her the mother of William Woodburn, grandson to Robert and Janet.
Annette