/b/ can occur at the start of words in Malay (e.g. barang 'thing', burong 'bird') and in the middle of words (e.g. habis 'finish', ibu 'mother'), but it can only occur at the end of words that are borrowed from Arabic (e.g. sebab 'because', wajib 'cumpulsory', adab 'good manners') or English (e.g. arkib 'archive', rizab 'reserve'). Note that, in the last two, English final /v/ becomes /b/ in Malay.
When these words have a final -an suffix, the /b/ tends to stay (e.g. peradaban 'culture', from the root adab). However, if the suffix is -kan, the final /b/ may actually be pronounced as [p]. For example, menyebabkan ('to cause', from the root sebab) is usually pronounced with [p] before the /k/ (see here), except perhaps in very careful speech.
This devoicing of root-final /b/ when a suffix starts with a voiceless sound is similar to what happens in English: 'describe' / 'description', 'absorb' / 'absorption'.
However, there is one word in Malay that seems strange: kewajipan ('obligation') has a /p/ in it, even though the root wajib has a final /b/ and the suffix is -an and not -kan. I cannot provide an explanation for this.