You just made a wet cell battery. A battery usually contains two types of metals separated by an acid. A chemical reaction between the two metals produces an electric current that continues until one of the metals is used up.
You can find wet cell batteries in cars but don't experiment with them, the electricity within a car battery can be very dangerous.
Find out more about how batteries work.