I opened up my project today as usual and discovered that my project wasn't synced with Gradle files, and the option to sync project with Gradle files is disabled. This issue has appeared twice now, I don't really know what I did the first time fixed it.
I don't think I've touched any files or settings before this happened.
Update: Seems like "Invalidate cache and restart" fixes the problem, but I'd still like to know why this happens? Also, recently this happens almost after every startup of Android Studio, I have to restart every time to make it work.