CountFormer: A Transformer Framework for Learning Visual Repetition and Structure in Class-Agnostic Object Counting