The reasons for quark confinement are somewhat complicated; there is no analytic proof that quantum chromodynamics should be confining, but intuitively confinement is due to the force-carrying gluons having color charge. As any two electrically-charged particles separate, the electric fields between them diminish quickly, allowing (for example) electrons to become unbound from nuclei. However, as two quarks separate, the gluon fields form narrow tubes (or strings) of color charge, which tend to bring the quarks together as though they were some kind of rubber band. This is quite different in behavior from electrical charge. Because of this behavior, the color force experienced by the quarks in the direction to hold them together, remains constant, regardless of their distance from each other.
The color force between quarks is large, even on a macroscopic scale, being on the order of 100 newtons. As discussed above, it is constant, and does not decrease with increasing distance after a certain point has been passed.
When two quarks become separated, as happens in particle accelerator collisions, at some point it is more energetically favorable for a new quark/anti-quark pair to spontaneously appear out of the vacuum, than to allow the quarks to separate further. As a result of this, when quarks are produced in particle accelerators, instead of seeing the individual quarks in detectors, scientists see "jets" of many color-neutral particles (mesons and baryons), clustered together. This process is called hadronization, fragmentation or string breaking, and is one of the least understood processes in particle physics.
The confining phase is usually defined by the behavior of the action of the Wilson loop, which is simply the path in spacetime traced out by a quark-antiquark pair created at one point and annihilated at another point. In a non-confining theory, the action of such a loop is proportional to its perimeter. However, in a confining theory, the action of the loop is instead proportional to its area. Since the area will be proportional to the separation of the quark-antiquark pair, free quarks are suppressed. Mesons are allowed in such a picture, since a loop containing another loop in the opposite direction will have only a small area between the two loops.
Compact Abelian gauge theories also exhibit confinement in 2 and 3 spacetime dimensions.