The equation comes from a probability principle, the fundamental counting principle. Essentially, it says that if there are X ways to do one thing and Y ways to do another, then there are XY ways to do both things. So where does the 2^n come from?
Let's look at a coin example first. Say we want to know how many ways we can flip a coin 1 time. Since there only two options for each flip (heads or tails), and we are flipping the coin one time, there are only 2^n, i.e. 2^1 = 2 outcomes when we flip only one time (heads or tails). Same with two flips. On the first flip, it has 2 options (heads or tails) and on the second flip, it has 2 options (heads or tails). Thus it has 2 x 2 (2^2) = 4 different outcomes: 1.) Heads/Tails 2.) Heads/Heads 3.)Tails/Heads 4.) Tails/Tails. Same idea with 5 flips. There are 2^5 = 2 x 2 x 2 x 2 x 2 = 32 different outcomes when we flip a coin 5 times.
You get the idea. Now with chromosomes, it is the same exact principle. A haploid number of chromosomes just means that there is one pair of each type of chromosome. After replication, this means that each chromosome will have 2 DNA molecules (chromatids). Regardless of what the haploid number is, each chromosome will have 2 DNA molecules after DNA replication. If we have a haploid number of 5, that just means that there are 5 different chromosomes, each containing two DNA molecules after replication. Thus, there are 2 x 2 x 2 x 2 x 2 (in other words, 2^5) = 32 ways that we can arrange the chromosomes.
Long response, but I know that the concept can be really confusing. I hope this helps!