But I thought Zero originally had the Zero Virus within himself, not the Sigma Virus. The latter was made when Zero accidentally infected Sigma, if X4 is anything to go by...
The virus had no known name when Zero was the carrier. However, since it's the same virus which became the Sigma Virus, it's still referred to as the Sigma Virus to denote the relation.
The Zero Virus is a more potent version of the Sigma Virus created during the Earth Crisis (X5). This is a new strain, not necessarily the same as the virus which Zero was originally infected with.
When Wily made the virus and inserted into Zero to make him and any reploid he comes in contact with turn Maverick, it didn't have a specific name; it was just called "virus".
Sigma Virus wasn't known until after Sigma started his rebellion, using the virus within himself to strengthen their negative thoughts and give them a reason to rebel against humans.
Both Zero and the virus were created before Reploids even existed. The original purpose of the virus wasn't to infect other machines, but to give Zero the power and drive to accomplish his mission: destroy Dr. Light's greatest creation.
The Sigma Virus became known when Doppler revealed its existence to X. The virus affects Reploids to varying degrees and Sigma may cause different effects with it. Reploids may be driven to follow Sigma's will or simply go haywire as the line between logic and emotion is blurred by the virus.
This.
As for how it got spread, I can't comment until someone can verify on when Zero actually started roaming around.
The virus was spread when Sigma started using it to infect other Reploids and machines.