I figured I'd chime in on the pre-NP review thread-rape discussion on Metroid Prime's origin since I just played Metroid Prime yesterday and read through all the lore entries again. The story contradicts itself quite a bit, and I haven't played Echoes at all, so I can't address anything brought up in it.
Twenty years before the start of the game, the meteorite struck Tallon IV, bringing Phazon with it. The impact, perhaps because of the Phazon, forcefully drew the moved-on-to-a-higher-plane Chozo back to the planet, where they tried to deal with it, failed, and sealed it away. The writings they left say that the Worm was in the meteorite. It seems to suggest the Worm is Metroid Prime, but it might just be the Phazon itself, which even the Pirates say has some lifelike qualities. The impact crater was sealed by almost magical Chozo technology.
The Pirates arrived sometime later. In fact, they are in the process of establishing the base on Tallon IV during the game. The vessel Samus raids at the beginning of the game is one of three that escaped Zebes after her rampage. It brought the Metroids to Tallon IV. The Pirates experimented on Metroids with Phazon, along with every other living thing they came across. They claim to have created Metroid Prime this way. It became hyper-aggressive, even for a Metroid, and they subdued it with cold. It kept mutating, eventually became strong enough to break free, assimilated their experimental weapons, and started killing everything until they ended up sealing it in a part of their Phazon mines, which somehow led to it being in the impact crater that the Chozo had sealed off to keep the Worm trapped.
I don't know if they chose one of those possibilities to be the canonical one for later games, or if they just left it unresolved. I kind of like the idea of the Phazon having an intelligence of its own, personally.