6. The parabola $y=a x^{2}$ intersects with the lines $x=1$, $x=2$, $y=1$, and $y=2$ to form a square. The range of values for $a$ is ( ).
(A) $\frac{1}{4} \leqslant a \leqslant 1$
(B) $\frac{1}{2} \leqslant a \leqslant 2$
(C) $-\frac{1}{2} \leqslant a \leqslant 1$
(D) $-\frac{1}{4} \leqslant a \leqslant 2$
6. (D).

From the problem, we know $a>0$. When $a>0$, the larger the value of $a$, the smaller the opening of the parabola, as shown in Figure 6. The square has vertices at $A, B, C, D$. When the parabola passes through $A(1,2)$ and $C(2,1)$, $a$ reaches its maximum and minimum values. At this time, $a=2$ and $a$
$$
=\frac{1}{4} \text {. }
$$