하다 is the verb 안녕 and 감사 are nouns
안녕 means peace ( and it can be used alone as a shortcut to 안녕하세요 if you're talking to a friend or someone younger than you ) so together 안녕 + 하다 = 안녕하다 the verb form of 안녕 and it means to be peaceful / calm / in a good health so 안녕하세요 means hello ( literally be in a good condition ) 하세요 is the imperative form of 하다
same thing with 감사합니다 , 감사 is the noun means gratitude , appreciation 하다 is the verb
together 감사하다 means to be thankful
and 감사합니다 is the verb conjugated and means I'm thankful ( thank you )