This is one of those cases where it is easy to take modern ideas for granted, and wonder how something so "obvious" could be missed. Modern formal logic with its array of logical operations, Boolean algebra and predicates is the creation of late 19th century, only finalized after much labor by Russell and Whitehead around 1910. Logical analysis that translates natural sentences into formally manipulable ones was also a 19th century invention (especially Frege's), and so was the axiomatic method (especially Pasch's, Peano's and Hilbert's). Stoics did introduce some propositional forms in the 3rd century BC, but not in relation to mathematics, and they never took. Between them and 19th century the only person to pursue propositional logic was Leibniz, who does list contraposition as a valid form in Generales Inquisitiones (1686). But like most of his logical works it was not published until 1902.
For everybody else formal logic was identical to Aristotle's syllogistic, where one could get from "all humans are mortal" to "all immortals are non-human", but which did not have expressive means for intricate mathematical reasoning. Friedman discusses in detail (pp.475-477) how expressive poverty of syllogistic impeded the rigorization of calculus. Since it was the only established formal logic flipping conditionals "blindly" would not have been kosher. And in the natural reasoning the difference between proof by contraposition and proof by contradiction is highly artificial, in both the conclusion is negated and the negation of something in the premise is derived. So discerning the use of "contraposition" before Leibniz is a matter of one's willingness to read between the lines. This said, according to Wirth, Fermat was particularly self-conscious:
"Fermat was the first who — instead of just proving a theorem — analyzed the method of proof search. Moreover, in his letter for Huygens and in [Diophantus, 1670], Fermat was also the first to provide a correct verbalization of proofs by Descente Infinie and to overcome the presentation of induction proofs as “generalizable examples”".
"For instance, in Euclid’s Elements, Proposition VIII.7 is just the contrapositive of Proposition VIII.6, and this is just one of several cases that we find a proposition with a proof in the Elements, where today we just see a corollary. Moreover, even Fermat reported in his letter for Huygens that he had had problems to apply the Method of Descente Infinie to positive mathematical statements... Because of the work of Frege and Peano, these logical differences may be considered trivial today. Nevertheless, they were not trivial before, and to understand the history of mathematics and the fine structure in which mathematicians reasoned, the distinction between affirmative and negative theorems and between direct and apagogic methods of demonstration is important".
P.S. Despite the common reading of Hilbert into Euclid, Euclid was not interested in building a deductive system from axioms and logic, and his "deviations" from this "task" are not oversights. He was interested in systematizing geometry, which he saw as an idealized representation of the "sensibles", a kind of "theoretical physics", and explicating common assumptions and types of reasoning used by geometers. These included reasoning from construction of diagrams, which was considered legitimate as long as they were used "indeterminately", see Acerbi's Euclid's Pseudaria (4.1). When contraposition remains valid in such reasoning is not a priori obvious, in general it fails in constructivism.