Search mexican war at this websitewww.archive.orgI search only Texts, not all media. You can find books published with units and names of solider's. Also best to spell out state names as older texts and records do not us modern short hand we use today. Illinois was Ill not IL before 1960 or so. TX was Tex, AR was Ark etc and their search engine will not find using IL TX or AR etc.
If you think he did live there look at the 1850 to 1880 census to see what state people named Baily were from. It should narrow it down for you.
He was regular Army, Graduate of West Point so I would think he commanded a Regular Army unit not a state militia unit.
Using Google Books a search result in a book that says Stephen was from b. Maine and was appointed from MA also another book has he as a second LT in the Army 1st Infantry 1841. Another says he was a Mexican War Veteran of the "1st Regiment of Infantry" and listed under 1st Lts with a notation was a 2nd Lt Sept 1847. There are more results to go through.