It is because of the hidden sound 'ㅂ'
여덟 is pronounced as [여덜] standalone or before consonant.
But, when it is followed by a vowel, it is pronounced as 여덜ㅂ
For example,
여덟이다 => [여덜비다]
여덟에 => [여덜베]
BTW, most young generation native Koreans tent to pronounce 여덟이다 as [여덜이다] nowadays.
The hidden consonant sound also occurs in French like 'restaurant, art'