For each carbon atom of the double bond, three of the four electrons are used in three sigma bonds, one to the other carbon atom of the double bond and the other two electrons to the other atoms. This leaves one electron on each carbon atom of the double bond not involved in sigma bonds. This electron is in a p orbital. This forms a pi bond.