@nico is right. the number of chromosomes is the result of an evolutionary timeline, puncutated by sometimes spontaneous events which shape the DNA.
These events occur in the course of evolution:
1) Chromosomal rearrangements. Large sections of the genome can flip around or become integrated in other chromosomes. By homologous recombination, regions of the genome can clip themselves out or duplicate themselves as well. If you look at the alignment of human to say chimp, there are many segments that move relative to each other.
2) chromosomal breaking or combination. Two smaller chromosomes may combine to form a larger one, or a larger one may break into two smaller chromosomes. An example of this is human chromosome 2, which is found as two smaller chromosomes in the great apes (see figure in wikipedia). We infer that this is a combination event exclusive to humans by comparing the other apes on the evolutionary tree. Birds and reptiles tend to have lots of chromosomal breakage, even to the point where the number of microchromosomes (less than 20 million bases). Mammals tend to be more conservative and not allow viable chromosomal breaks - chickens have 78 chromosomes to our 23..
3) idiomatic chromosomal behavior. Sex determining chromosomes are examples of chromosomes where a pair becomes distinctly different in size and composition.
Another example is in trypanosome which has many tiny DNA segments which code for variant surface coat proteins.
4) @rwst points, what I clean forgot, that occasionally (like maybe just a few times) there have been whole genome duplications. This can be identified by chromosomal alignments within a single genome and has not happened very often since we became eukaryotic metazoans. Not sure how many times, but perhaps just once or twice in our lineage. If anyone knows about animals/humans that would be great. As you can see the link shows whole genome duplications in plants, which don't seem care how many chromosomes there are. Plants have polyploidy, you see, so such duplication events are much better tolerated. On the other hand plants can't play video games.
P. Dehal, J. L. Boore: Two rounds of whole genome duplication in the ancestral vertebrate. In: PLoS biology. 3, 10, Oct 2005, e314, doi:10.1371/journal.pbio.0030314. PMID 16128622. PMC 1197285.
You can see that these events happen at particular moments and help shape the species and the composition of the chromosomes. It is not a priori possible to predict the number or type of chromosomes just by looking at an animal, but only by looking at the related animals.
Fungi and Plants have even more variations in chromosomal composition than animals.