The only way to tell the difference between barn and barn is context. Barn means 'child' and 'children.'
The 'the' forms give additional information, however. 'The child' is barnet, where 'the children' is barnen. This is a very common 'conjugation' in Swedish. CF 'brev'. Letter and letters are both brev. However, the letter and the letters are brevet and breven.
Dig and er are the object forms of the pronouns you listed. Du/dig is the singular second person pronoun (you singular) and ni/er is the second person plural (you plural). For example, "Jag älskar er" means "I love you (plural)" and "Jag älskar dig" means "I love you (singular)."
“er” is the object form of “ni,” second person plural (“you” plural). It doesn’t have anything to do with en/ett words but rather whether it is the subject or object of a sentence. It’s like the usage of he vs. him. Examples: Ni är så roliga! - You (plural) are so funny! Jag älskar att hänga med er. - I love hanging out with you (plural).