Many file types can just be copied in continuation of a basic file. Nothing special here.
It's up to the file interpreter to detect the actual content.
In your case (JPEG + ZIP), most image readers (image interpreters) will correctly display the image file since the content is complete and ignore the rest (the ZIP at the end) as junk/metadata.
The ZIP extractors (archive interpreters) will search for the archive specific tag types. When they find it somewhere in the file, they will know an archive is there. The archive extractors this time will ignore what is not indexed by the archive system as metadata and read the indexed content, so that is why this trick actually works.
Basically, appending any file type to the JPEG will still display it when viewed, but for the rest of the content (what files you add after) it's a matter of what and how interprets them.