The question of mitzvos tzrichos kavanah is a dispute in the Amoraim. The ruling of the ruling of Shulchan Aruch (OC 60:4), at least by a biblical commandment, is that kavanah lotzeis - the intent to fulfil the obligation:
יש אומרים שאין מצות צריכות כוונה, ויש אומרים שצריכות כוונה לצאת בעשיית
אותה מצוה, וכן הלכה:
With regards to kriyas shema specifically, the Shulchan Aruch writes (60:5):
הקורא את שמע ולא כיון לבו בפסוק ראשון שהוא שמע ישראל לא יצא ידי חובתו
והשאר אם לא כיון לבו אפילו היה קורא בתורה או מגיה הפרשיות האלו בעונת
קריאת שמע יצא והוא שכיון לבו בפסוק ראשון:
A casual reading of the Shulchan Aruch may lead to the conclusion that the intent to fulfill the obligation is only crucial in the first verse. However, it is evident in the Rishonim in Berachos that this law is not discussing the intent to fulfill the obligation, but the understanding of the meaning.
The Mishne Berura brings two conflicting opinions on how to understand the Shulchan Aruch, whether he means to limit to requirement of concentrating on the meaning to the first verse, or the intent to fulfill the obligation.
ונה זו האמורה כאן איננו הכונה האמורה בסעיף ד' דשם הוא הכונה לצאת ידי חובת
מצוה זה בעינן לכל הפרשיות [כמו שכתב הריטב"א בר"ה ושיטה מקובצת בברכות]
משא"כ כונה זו הוא להתבונן ולשום על לבו מה שהוא אומר ולכך הוא לעיכובא
רק בפסוק ראשון שיש בו עיקר קבלת עול מלכות שמים ואחדותו ית' וי"א שאפילו
כונה לצאת הוא לעיכובא רק בפסוק ראשון
Accordingly, if one didn't have intent to fulfil the obligation of Shema, one would not have 'accidentally been mekayem the morning shema' - at least in the the first verse, and according to most opinions, the rest of Shema too.
Even in situations where intent is not required, most Rishonim agree that if one has specific intent not to discharge his obligaton, he doesn't discharge his obligation. (See, for example, Tosfos to Sukka 39a 'דאע"ג דאמרי' בסוף ראוהו ב"ד (ר"ה כח:) דמצות אינן צריכין כוונה מ"מ בעל כרחו לא נפיק '.)