Tapeworms (or more technically, the class "Cestoda") are parasitic flatworms that generally live in the intestine of mammals, causing digestive problems in the host as well as often stripping the body of necessary nutrients. There are several different types of tapeworm, but they share a common infection source - the eggs or larvae are found in other animals which are then consumed by the host. The eggs or larvae grow in the host and draw nutrients from the digestive system, and lay their eggs in the feces. These generally re-infect the animal that was eaten to complete the worm's life cycle.
Tapeworm can grow to immense lengths, with worms in excess of 30 feet long not being uncommon.
The best way to prevent tapeworm is to thoroughly cook pork and fish, the two main sources of the larvae.