Actions are judged by intentions
إِنَّمَا الْأَعْمَالُ بِالنِّيَّاتِ، وَإِنَّمَا لِكُلِّ امْرِئٍ مَا نَوَى، فَمَنْ كَانَتْ هِجْرَتُهُ إِلَى دُنْيَا يُصِيبُهَا أَوْ إِلَى امْرَأَةٍ يَنْكِحُهَا، فَهِجْرَتُهُ إِلَى مَا هَاجَرَ إِلَيْهِ
Narrated 'Umar bin Al-Khattab: I heard Allah's Messenger (ﷺ) saying, "The reward of deeds depends upon the intentions and every person will get the reward according to what he has intended. So whoever emigrated for worldly benefits or for a woman to marry, his emigration was for what he emigrated for"
Narrated by Umar ibn al-Khattab
Translation: sunnah.com English, via fawazahmed0/hadith-api
The lesson
The same act can be worship or habit. What turns it into worship is the intention behind it.
Sources
Sahih al-Bukhari 1Sahih
Read on sunnah.com (opens in a new tab)Sahih Muslim 1907aSahih
Read on sunnah.com (opens in a new tab)