As a child, there is something delightful about learning curse words. Children know that they shouldn't say them but when out of earshot from parential influence, the language can turn the air blue.
It's not that children know the full meaning or context of these words- the delight comes from the act of transgression- of doing something that is frowned upon by adults.
There is also alot of laughter in such behaviour. Adults can seem absurd from the child's perspective. These 'mere' words can shock an adult which gives the child an immense sense of power.
Similar behaviour is shown in young children when they 'play fight.' I have a nephew who likes to punch me as hard as he can to see if he can make me cry! He doesn't mean any harm by it, he is only testing his own strength. Such behaviour is natural.
Curse words are a device to try and put adults off balance and this is magic when it works!