On James' birth they were married.
If Edward and Mary weren't married it would only state the Mothers name and would also state illegitimate.
There are a few years missing in the marriages March 1816 to 8th Jan 1822.
Names are repeated so the later marriage would possibly be another couple with the same names.
Going by the Baptism I would say they were married earlier, just that the years are missing for the marriage.
The marriage you found in 1846, it's not listed in the site below, which is a pain as most are and you would have seem more information.
On the Baptism on the 26th May 1823. William Grennan of Edward Grennan (though not stated as it says the surname for William) and Ellen Lamb.
Sponsors as you said Edward and Mary. Now this could be Edward the father stood for him and an Ellen Lamb.
This is how I see it as an explanation.
Welcome to Irish Genealogy - Irish Genealogy