Note this is a very similar question to the one you posted
here.
Since you've asked this twice, perhaps a bit of explanation is in order. You may be aware that 'to do' is called an infinitive, and 'doing' is called a gerund. Certain verbs can be followed by either a gerund or infinitive with little difference in meaning.
See item 14
here for an explanation of those minor differences. (cease doing/cease to do - from your other similar post)
See
here for for examples of adjective + prepositions followed by gerunds (afraid of doing) . The simple rule is that gerunds (versus infinitives) are used after prepositions.
See
here for examples of 'be + adjective' combinations followed by infinitive (afraid to do). There are many 'be + adjective' expressions which are followed by infinitives. Although 'be afraid' isn't on the list, it falls into this category.