The mean number of 3‐torsion elements in the class groups and ideal groups of quadratic orders