The Brownian motions of microscopic particles in viscous or viscoelastic fluids can be used to measure rheological properties. This is the basis of recently developed one- and two-particle microrheology techniques. For increased temporal and spatial resolution, some microrheology techniques employ optical traps, which introduce additional forces on the particles. We have systematically studied the effect that confinement of particles by optical traps has on their auto- and cross-correlated fluctuations. We show that trapping causes anticorrelations in the motion of two particles at low frequencies. We demonstrate how these anticorrelations depend on trap strength and the shear modulus of viscoelastic media. We present a method to account for the effects of optical traps, which permits the quantitative measurement of viscoelastic properties in one- and two-particle microrheology over an extended frequency range in a variety of viscous and viscoelastic media.