When the Gemara on 13b says that these words are referring to Torah study, it is talking about the words "לדבר בם" in the second passage of Shema. The source for the recitation of Kerias Shema is from the words "ודברת בם" in the first passage of Shema. Thus, there is no contradiction. As Rashi says:
'ה"ג ההוא בדברי תורה כתיב. כדמוכח קרא ולמדתם אותם את בניכם וגו
It should be noted, however, that this is actually a dispute among the amoraim. On 21a R. Yehuda holds that the entire mitzvah of Kerias Shema is only derabanan, and even the words in the first passage of Shema are referring to Torah study. Tosafos there brings up the Gemara on 2a which cited the verse of ובשכבך, and says that (according to R. Yehuda) that is just an asmachta b'almah.