...As a result of a symbiosis between prokaryotic and eukaryotic cells. The theory is that the mitochondria and the chloroplasts were prokaryotic cells inside the eukaryotic cells which is called endosymbiosis. There is evidence for this because plastids and mitochondria have double membranes like prokaryotic cells and they also have their own genetic material.
Hope that helps and is in decent english as I studied it in spanish