You will find that these countries were usually part of the empire of the country whose language is now used as the official language.
In many countries, the use of an 'outside' official language is often retained as a useful means of communication when there are many native languages. O don't know how many native languages there are in Sierra Leone, but to look at another country as an example, Nigeria has over 250 different native languages. To pick one as 'the' official language is politically and socially difficult. To use a neutral 'outside' language to enable all these different tribes to communicate wherever they are in the country makes a lot of sense.