It evolved from engulfed prokaryotes that were once living as an independent organism. A eukaryotic cell engulfed an aerobic prokaryote which formed an endosymbiotic relationship with the host eukaryote and developed into a mitochondria. Hope this helps :) lmk if I’m wrong plz