How to add a checkbox with categories of entries to the form Contact Form 7 WordPress

I am not sure about

subcategories that will expand only after clicking

I have never seen any form fields that does this.

However, you can use the dynamic_dropdonw field available in the Smart Grid-Layout Extension for CF7 plugin. It allows you to build a select2 droddown field using a category. Select2 js are quite cool with automatic listing of options when you type. Try it out and see if this helps.