The more you learn and cast spells, the more you are a spellcaster. All roles have some ability to learn and cast spells.
Whether to wear armor that reduces spellcasting success rate is a strategic choice. Some heroes wear metal armor most of the time and take it off specifically for spellcasting, eg clerical, divination and healing spells, or when preparing for combat, eg protection, confuse monster, and haste self. A hero who eschews metal armor, so that they may freely use Attack and Enchantment spells as they encounter monsters, is primarily a spellcaster. Wearing a robe, usually as a starting item or taken from an aligned priest, is a spellcaster option.
In the early game, even wizards will sometimes wear metal armor; any hero who has depleted their energy may as well wear metal armor while they regain energy. In the late game, most of the ascension kit armor items do not hinder spellcasting anyways, such as boots of speed, helm of brilliance, and dragon scale mail. High-level, high-intelligence characters often have good spellcasting success rates even if they wear gauntlets of power and/or a small shield.