Mitochondria and chloroplasts display similarities with bacteria that led to the endosymbiont theory. This theory states that an early ancestor of eukaryotic cells engulfed an oxygen-using nonphotosynthetic prokaryotic cell. Eventually, the engulfed cell formed a relationship with the host cell in which it was enclosed, becoming an endosymbiont (a cell living within another cell). Indeed, over the course of evolution, the host cell and its endosymbiont merged into a single organism, a eukaryotic cell with a mitochondrion. At least one of these cells may have then taken up a photosynthetic prokaryote, becoming the ancestor of eukaryotic cells that contain chloroplasts.
This theory is consistent with many structural features of mitochondria and chloroplasts. First, rather than being bounded by a single membrane like organelles of the endomembrane system, mitochondria and typical chloroplasts have two membranes surrounding them. (Chloroplasts also have an internal system of membranous sacs.) There is evidence that the ancestral engulfed prokaryotes had two outer membranes, which became the double membranes of mitochondria and chloroplasts. Second, like prokaryotes, mitochondria and chloroplasts contain ribosomes, as well as circular DNA molecules—like bacterial chromosomes—associated with their inner membranes. The DNA in these organelles programs the synthesis of some organelle proteins on ribosomes that have been synthesized and assembled there as well. Third, also consistent with their probable evolutionary origins as cells, mitochondria and chloroplasts are autonomous (somewhat independent) organelles that grow and reproduce within the cell.
Urry, Lisa A.. Campbell Biology. Pearson Education. Kindle Edition. https://www.pearson.com/us/higher-education/series/Campbell-Biology-Series/2244849.html