My full answer was too long, so I've cut out my argument for three cases in Romanian rather than five, but see here "
https://en.wikipedia.org/wiki/Romanian_grammar" , section 1.3 Case.
Now, the decision of which case to use, that depends on the function of the word in the sentence. Here we talk about subject, direct object, and indirect object. Consider this English sentence:
"The woman gives the boy the ball."
1. Subject. Who is doing the giving, or who is doing the action of the verb? In this sentence, it's "the woman." The one doing the action of the verb is called the "subject" of the sentence. "The boy" or "the ball" is not doing the action of the verb, so those are not the subject.
In Romanian, as in many European languages, for the subject of the sentence you use the nominative case form.
2. Direct object. Who or what receives the action of the verb? This is a little tricky. What she is giving is "the ball," which is therefore the direct object of the sentence. One might think that "the boy" receives the action of the verb, but that's not the situation here. If the woman picks up the boy and gives him to another person, then "the boy" receives the action of the verb, and is the direct object.
In Romanian, as in many European languages, for the direct object of the sentence you use the accusative case form.
3. Indirect object. Who or what receives the direct object? It is "the boy" in this sentence. The one receiving the direct object is called the "indirect object."
In Romanian, as in many European languages, for the indirect object of the sentence you use the dative case form.
Similar for genitive case, where the general idea is "possession."
Well, I've written a lot, maybe TMI. The same principle applies in German; there the issue is how to decide whether to use "der," "die," "das," "den," or "dem," or "des." I can give German examples, if you like.
I'll leave it to someone else to answer your specific questions about Romanian.
Hope this helps
Garry