Why does the word with the index 0 in the vocabulary also have the index 0 in the embedding?

I was just wondering how the embedding layer knows what index the different words should have in the vocabulary. In other words, why does all indexes in the vocabulary and embeddings match?

Your question is unclear. Why would they not be the same?

The embedding layer doesn’t know. It’s your job to ensure that it matches :).