My science teacher told us that all mammals have round about the same number of genes. This confuses me, since there are very big and very small mammals. Where do genes come from and why do animals have such large differences in size between one another even if they have around the same amount of genes?
Genes are the "plans" for proteins in an organism; in turn, those proteins do all sorts of things, catalyzing chemical reactions and making up much of the structure of an organism.
A hippo is much bigger than a mouse, but it isn't that much more complex: both are going to have the same sorts of organs like a heart, lungs, kidneys, liver, brain. If you look at an individual cell from each animal from the same tissue, they will probably look almost identical! They are going to have similar metabolic pathways, etc. Their genes will be different, because some differences in proteins are necessary to build organisms of different structure and size, but the number of genes doesn't have to vary much, the hippo just needs to produce a lot more of the gene products, not have more plans.
A hippo will of course have way more genetic material, because it also has more cells and there is a copy of the DNA in every cell, but what your teacher is talking about is the number of genes within each cell.
Ultimately, genes come from evolution. You can read more about the basics of evolution somewhere like Berkeley's Evolution 101.