It may be a bit hard to believe but modern wall-to-wall carpeting begins as a bin of plastic pellets. The pellets are melted and forced through a sieve, much like the one in your kitchen. The emerging stream of melted plastic is then allowed to free-fall to a room below, solidifying into a polymer thread.
The carpet thread is wound onto spools and hundreds of the spools are loaded onto a massive loom that weave the fiber into the backing of the carpet. Watch the video, it's really quite fascinating.