Electric trains either have overhead power cables (eg Bedford to London Farringdon) or there is a third track which is live (London Farringdon to Brighton). In the first case there is a conductor (not a member of the railway staff) on the roof of the carriage which makes the circuit in the latter, there is a conductor at wheel level which makes the circuit. In both cases they ultimately earth through the normal track via the metal wheels. Diesel trains are powered by diesel engines.
Then of course, you have Diesel Electric trains, in which the diesel engine drives a generator that supplies electicity for the motors. Before that you had steam trains and even before that the first railways were horse drawn. When there was a penal colony in Australia, Tasmania even had a convict powered railway!
Not quite right Answerbok - the Snowdon Mountain Railway is powered by a rack and pinion system where a gear on the loco engages with a rack in the middle of the track. Interestingly, the locos are not connected to the carriages! It's well worth a visit, as is the nearby Dinorwig "Electric Mountain".