I think the question is very badly worded, as it's not really clear what it means by "each group has..". With the way it's worded, it implies that you have to share out the pens and pencils equally among an unspecified number of groups. Without knowing the number of groups, this makes the question unsolvable: for example, if you had $3$ groups, then you'd need to buy $2$ packs of pencils and $1$ of rubbers. But if there were $16$ groups, then you'd need $4$ packs of pencils and $2$ of rubbers.
It seems that what the question is trying to ask is:
> Judith wants to buy a certain number of packs of pencils and rubbers so that she has the same amount of each.
In which case, the answer is as the teacher has said. But this is far from clear.