I have a collection of photos taken from my digital camera. All of them were taken with the same settings (same resolution etc...). However all these pictures have different file sizes. Why is this? Could it be because of the colors or something?
JPEG and many others formats use compression algorithms to optimize the file size, which will cause it to depend on the content.
A picture with more gradients, colors and details should generate a bigger file in size than one containing simpler forms, even if both use the same resolution and compression level.
Unlike JPEG, file formats like BMP and TGA do not use compression and their size will depend only on the resolution and color depth of the pixels.
JPEG compression takes advantage of color zones, or blocks of similar information in the file. Described at the simplest possible level, if two pixels next to each other are the exact same color (or close enough that JPEG thinks the human eye can't tell), it simply maps the value of pixel2 to reference the value of pixel1, rather that storing it uniquely (at a very simple level, this is how file compression of all types works).
This is why, sometimes, when viewing (decompressing) a low-quality JPEG file, you'll get weird blocks of color that don't represent gradients well, or sometimes you'll see gradient "banding", in a picture of a sunset or something. These are called artifacts, and they're caused when a JPEG is saved with low quality settings, therefore taking a more extreme approach on size optimization.
You may have heard someone on a forum say "needs more JPEG" when someone posts a low-quality image. This has been a running joke on the internet for a while now, even leading to sites like http://needsmorejpeg.com/