These are two different, conflicting and thus contradictory versions based on variant traditions.
The older tradition is the one in which Heracles actually interacts with the Titan Atlas, who helps him to procure the apples of the Hesperides.
In the later version, in which Perseus had turned Atlas to stone generations before Heracles' birth, Heracles himself acquires the apples after a fight with the guardian dragon of the Hesperides' garden, which is sometimes located in the mountains which Atlas' body had become.
The oldest mention of this second version that I have encountered is a fragment of the 5th-century BC poet Polyeidus preserved in the 12th-century AD encyclopaedia called the Etymologicum Magnum, wherein Atlas is called simply "a shepherd" who was turned to stone by Perseus. The fullest surviving account of this version of which I am aware is given to us by the Roman poet Ovid in his Metamorphoses (written roughly 400 years after Polyeidus).
William Smith's Dictionary of Greek and Roman Biography and Mythology says that:
In the Homeric description of Atlas, the idea of his being a
superhuman or divine being, with a personal existence, seems to be
blended with the idea of a mountain. The idea of heaven-bearing Atlas
is, according to Letronne, a mere personification of a cosmographic
notion, which arose from the views entertained by the ancients
respecting the nature of heaven and its relation to the earth...
[L]ater traditions distort the original idea still more, by putting
rationalistic interpretations upon it, and make Atlas a man who was
metamorphosed into a mountain. Thus Ovid (Met. iv. 630,&c., comp. ii.
296) relates, that Perseus came to him and asked for shelter, which he
was refused, whereupon Perseus, by means of the head of Medusa,
changed him into mount Atlas, on which rested heaven.