ㄷ can be pronounced as ㄴ, ㄸ, ㅈ
1) 문 닫는다 [문 단는다]
⇒ You can figure out why it's like that if you think how 't' is pronounced in "Look at Nice(a city in France)"
2) 닫다 [닫따]
⇒ㄷ+ㄷ=ㄸ
3) 굳이 [구지]
⇒ ? It's called "palatalization", you have to memorize them - they are few.
ㅂ can be pronounced as ㅁ, ㅂ, ㅃ
1) 밥 먹어 [밤 머거] ⇒ "Let me see"
2) 국밥 [국빱]
If one syllable ending with ㄱ / ㄷ / ㅂ / ㅅ / ㅈ / ㅊ / ㅌ / ㅍ combines with another syllable ending with one of those aforementioned, the latter one is doubled.