First, in is a variable preposition, meaning that the case of noun that follows depends on the meaning using in the sentence. In the first sentence, the action is all taking place in one location, and in that situation you use the dative case with in. In the second sentence describes a movement into a location, and in that situation you use the accusative case with in. So the reason that words are different is that einem guten Restaurant is in the dative case and ein gutes Restaurant is in the accusative case.
The noun itself, Restaurant is the same in both dative and accusative. But the article used is einem in the dative and ein in the accusative (since Restaurant is neuter). Finally, the adjective gut, since it precedes a noun, is declined according to the situation. When an adjective does not follow a article or other determiner, or if it follows ein or another determiner ending -ein (for example mein), then it's usually declined in the same pattern as der. In this case, the accusative neuter of der is das so gut is declined with an -es ending. (The only exception to this rule is in the genitive with masculine or neuter nouns; that combination doesn't occur often and not here so that's a topic for another question.) So for the accusative case "a good restaurant" translates as ein gutes Restaurant. When an adjective follows an article or determiner other than one ending -ein, then the adjective follows a different, simplified declension pattern. The ending in this case is always either -e and -en. The rule is that plurals are declined with -en, dative and genitive are declined with -en, masculine accusative is declined with -en, and all other combinations are declined with -e. In this case it's the dative so the -en ending is used, and gut is declined as guten. So for the dative case "a good restaurant" translates as einem guten Restaurant. (Most grammars use a system of strong, weak, and mixed declension patterns for adjectives, but the above is a summary of the way I remember it.)
German declension patterns are more complex and detailed than those in English, which can be a challenge for people learning German. (Not that English doesn't have its own challenges.) So one thing you have to recognize is that the same phrase in English may use different word endings in German, and you have to learn special rules to figure out what those endings should be in a given situation.