You're talking about a photo's EXIF data. It's metadata embedded into photographs by the device taking the pictures. Often it includes:
- Device information (model, sometimes serial number)
- Photograph information (Resolution, aperture, focal length, size, etc)
- GPS Information (Lat, Long)
There are tools out there to strip EXIF data from pictures if you're concerned about it. See these Google Results for more info.
EDIT -- How Metadata Works
Metadata is simply additional information about the file. All (I guess I should say most) files have some sort of metadata associated with them, including create date, modified date, metadata change date, and last access date (research tools like IMG_CAT, FLS, and iStat for more info on obtaining metadata).
Basically, a file is nothing more than a sum of binary data (1s and 0s), so metadata is additional binary added to the binary that makes up the image. It's located in a specific area of the file (known as the offset, usually represented in hex i.e., 0xLOCATION) and can be observed with the tools mentioned above or by opening the image in a hex editor given that you know where to look for it. This illustration may help understand how metadata is packaged into the file.