Having done quite a bit of genealogy using census, they did indeed count non-citizens. In some years, they asked if the person was naturalized, year of naturalization, and country of origin. But I’m thinking in those days they were mostly legal immigrants.
I think they should only count legal immigrants. But if you think about it, that is the actual problem — that we can COUNT illegals, but can’t deport them. And if you decide to let people stay in the country, they are defacto “legal” whether you call them that or not.