A function is a mapping which assigns, to every element from the starting set, in this case the -element set, exactly one element from the target set, in this case the -element set.
As this mapping has to be done for each of the elements from the starting set, or domain, we might as well line all those elements up and see which elements from the codomain (or target set) can be assigned to them.
To the first element of the domain, we may assign any of elements of the codomain. Likewise, to the second, third,..., -th element we can also assign any of the elements from the codomain, as there are no restrictions.
So, there are elements in the domain, and to each one of them, via different functions, we may assign any of those elements from the target set. From this and the product principle, it follows that there are different functions from a -element set to a -element set.