Sometimes, we use 'the' instead of 'a' or 'an'.
We use 'the' when we are talking about a specific thing, when we are looking at or thinking about one special thing.
We use 'a' and 'an' when we are talking about general things, when we are not thinking about one special thing.
In the first sentence, I don't know which cake I want, I just know I want a cake.
In the second sentence, I don't want any cake, I want one specific cake! I want the cake.