Well, nouns and adjectives don’t exist all by themselves, but they play a role in a sentence. In English, this role is determined mainly by word order, and sometimes a preposition, but in German, you have more freedom concerning the word order, as the information about the role within the sentence lies in the case of the noun. The subject of a sentence is always in the nominative case. Anything that belongs to something/someone is in the genitive case.
Then you have verbs that take objects. Let’s take this simple example: “I give my sister a book” – or with a different word order: “I give a book to my sister”. In German this translates to: “Ich gebe meiner Schwester (Dativ) ein Buch (Akkusativ)” or in a less common word order: „Ich gebe ein Buch (Akkusativ) meiner Schwester (Dativ)“. In English you need the preposition „to“ to clarify what is given and who is the person the object is given to. In German, this information is in the cases.
Now this was an example with two objects. In such cases, the object carrying the English “to” usually translates to a German dative, while the other object requires the accusative. This might be a rule of thumb you want to learn – although there are lots of exceptions to this.
Many other verbs carry only one object. Whether this object has to be in the dative or accusative case depends on the verb, and I don’t know of any rule that tells you which one to use. But it’s always the verb that determines which cases have to be used as object(s).
Last but not least, you have prepositions. These also require a particular grammatical case for the nouns that follow them. Sometimes they can be used together with different cases, but then the meaning changes with the case that is used. A popular example is: “in” + dative corresponds to the English “in”, while “in” + accusative translates to “into”.
The bottom line is: It is the verbs and the prepositions that determine which cases have to be used in a sentence.