hello, I wonder why sometimes the form "Freunde" is used for plural and other times the form "Freunden"?
It depends on the case. "Freunde" is used for the nominative, genitive and accusative plural; "Freunden" is used for the dative plural. In the dative plural, all nouns get an extra "-n".
The only exception are nouns whose "basic" (= nominative) plural form, i.e. the one you find in a dictionary, ends in "-n" (e.g. "Frauen") or "-s" (e.g. "Autos"). These nouns don't get an extra "-n" in the dative plural.