I know that you can find the number of functions that map $A \to B$ through $|B|^{|A|}$, but I don't understand how this works? If $A={1,2,3}$ and $B={h,t}$, and for every element in $B$, there are $3$ elements in $A$ that it maps to, then it sounds like the answer is $6$, but the actual answer is $8= 2^3$. This just doesn't make sense... Can someone explain this to me?

Also, how would you write a a set of functions? Would it be a set of ordered pairs? If so, then wouldn't the answer be:
$\{{(h,1), (h,2), (h,3), (t,1), (t,2), (t,3)\}}$