How to understand the compile procedure of build.gradle

Besides the project’s build and compile stuff, which has lots of documents to explain it, I just want to know the compile stuff of the gradle file.
For example, the simplest build.gradle looks like:

buildscript {
    ext.kotlin_version = '1.5.21'
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.5.21'
    id 'java'
}

dependencies {
}

How could gradle recognize these functions like plugins and dependencies?
Just because the file is named build.gradle and these functions are in the specific gradle api package?

I just try to understand the basic compile logical.
Thanks.