It was not an election, it was a coup. In 1978, Taraki led a group of Khalq and Parcham communists in a coup d'état that overthrew the Afghan government of Mohammed Daoud Khan. The coup was supported by the Soviet Union, which wanted to establish a communist government in Afghanistan.
The Revolutionary Journey of Nur Muhammad Taraki: Test Your Knowledge!