A soldier was a participant of a military conflict, or any member of a military, regardless of position.
Bajoran First Minister Shakaar Edon remarked to Odo in 2372 that "You know, I've been a soldier, and I've been a politician. And I have to say I'm beginning to think that... being a soldier was easier." (DS9: "Crossfire")
Following the Occupation, Bajorans no longer followed the D'jarra caste system. In 2372, Kira Nerys remarked that "Artists have become soldiers, priests have become merchants, and farmers have become politicians." (DS9: "Accession")
Though not strictly a military organization, Starfleet sometimes put its members in the position of being soldiers. Miles O'Brien often talked about his time as a soldier while fighting the Cardassians. (TNG: "The Wounded", DS9: "Empok Nor")