Young children often swear because they’re exploring language. They might be trying out a new word or attempting to understand it's meaning. When school-age children swear, it's usually because they are trying to vent some negative feelings. It's a response to something painful, upsetting or frustrating.
Children might also swear to fit in socially with their peers. They might be trying to be part of a certain group, trying to stand out by being funny or by adding shock value to their talk. Children might also be imitating others when they swear.