How prokaryotic autotrophic cells were formed after the prokaryotic heterotrophic cells?
This event is generally coined as the endosymbiotic theory. It was first believed that the first lives that have evolved on earth's surface are the heterotrophic prokaryotes. This has happened at around 3.6 billion years ago where the atmosphere is completely different from the present. These organisms convert the chemical compounds in the environment in order for their metabolisms to push through. At around 3.4 billion years ago, photosynthetic organisms have evolved.
Eventually, the heterotrophic prokaryotes engulfed the photosynthetic organisms and have lived together as a single organism for over a long period of time. This resulted in the production of prokaryotic autotrophic cells.